Get custom field outside the loop array

2019-09-20 09:43发布

I'm trying to the $appLink variable with a custom field value outside of the loop. I'm using Wurfl to detect the users device, I'd like to echo the custom field value for the URL. This is what I have but I can't get it to work. Can anyone help please?

 else if ($os == 'iOS') 
  {  
  global $wp_query;
  $postid = $wp_query->post->ID;
  $appLink = echo get_post_meta($postid, 'ios_app_link_sb', true);
  wp_reset_query();
  } 

标签: php wordpress
2条回答
闹够了就滚
2楼-- · 2019-09-20 09:48

Try this debug $postid.

Print_r($id)

if $postid is true, you check name key meta 'ios_app_link_sb' is exist value?

查看更多
Animai°情兽
3楼-- · 2019-09-20 10:02

It should be either

 echo get_post_meta($postid, 'ios_app_link_sb', true);

or

 $appLink = get_post_meta($postid, 'ios_app_link_sb', true);
 echo $appLink;
查看更多
登录 后发表回答