wordpress打印自定义数组

时间:2013-06-19 20:38:28

标签: php arrays wordpress

我正在使用wordpress插件来显示有关商家的信息。但我只想在页面中显示很少的字段。

$post_id = the_ID();<br/>
$customContent  = get_post_custom($post_id);<br/>

返回:

Array (<br/> 
[_yoast_wpseo_google-plus-description] => Array ([0] =>)<br/> 
[_yoast_wpseo_opengraph-description] => Array ([0] =>)<br/> 
[_yoast_wpseo_sitemap-prio] => Array ([0] => -)<br/> 
[_yoast_wpseo_canonical] => Array ([0] =>)<br/> 
[_yoast_wpseo_redirect] => Array ([0] =>)<br/> 
[_yoast_wpseo_sitemap-include] => Array ([0] => -)<br/> 
[_yoast_wpseo_meta-robots-adv] => Array ([0] => none)<br/> 
[_yoast_wpseo_meta-robots-nofollow] => Array ([0] => 0)<br/> 
[_yoast_wpseo_meta-robots-noindex] => Array ([0] => 0)<br/> 
[_yoast_wpseo_metadesc] => Array ([0] =>)<br/> 
[_yoast_wpseo_title] => Array ([0] =>)<br/> 
[bs_sunday_open] => Array ([0] =)<br/> 
[bs_sunday_close] => Array ([0] =>)<br/> 
[detail_active] => Array ([0] => 0)<br/> 
[_yoast_wpseo_focuskw] => Array ([0] =>)<br/> 
[bs_friday_open] => Array ([0] =>)<br/> 
[bs_friday_close] => Array ([0] =>)<br/> 
[bs_saturday_open] => Array ([0] =>)<br/> 
[bs_saturday_close] => Array ([0] =>)<br/> 
[bs_thursday_close] => Array ([0] =>)<br/> 
[bs_tuesday_close] => Array ([0] =>)<br/> 
[bs_tuesday_open] => Array ([0] =>)<br/> 
[bs_monday_close] => Array ([0] =>)<br/> 
[bs_monday_open] => Array ([0] =>)<br/> 
[bs_video] => Array ([0] =>)<br/> 
[bs_yelp] => Array ([0] =>)<br/> 
[bs_twitter] => Array ([0] => twitter/xyz)<br/> 
[bs_facebook] => Array ([0] =>facebook/xyz)<br/> 
[bs_gplus] => Array ([0] =>)<br/> 
[bs_images] => Array ([0] => a:1:{i:0;s:54:\"xxx/yyylogo.png\";})<br/> 
[bs_publisher_review] => Array ([0] =>)<br/> 
[bs_menu] => Array ([0] =>)<br/> 
[bs_website] => Array ([0] => www.xyz.com)<br/> 
[bs_phone] => Array ([0] => 0123 456 7899)<br/> 
[bs_postal] => Array ([0] => A11 111)<br/> 
[bs_state] => Array ([0] =>)<br/> 
[bs_city] => Array ([0] => London)<br/> 
[bs_address_2] => Array ([0] => xyz STREET)<br/> 
[bs_address_1] => Array ([0] => xyz)<br/> 
[bs_phone_number] => Array ([0] =>)<br/> 
[bs_thursday_open] => Array ([0] =>)<br/> 
[bs_wednesday_close] => Array ([0] =>)<br/> 
[bs_wednesday_open] => Array ([0] =>)<br/> 
[bs_twitter_id] => Array ([0] =>)<br/> 
[_yoast_wpseo_linkdex] => Array ([0] => 0)<br/> 
[bs_twitter_hashtag] => Array ([0] =>)<br/> 
[bs_facebook_hashtag] => Array ([0] =>)<br/> 
[bs_update_source] => Array ([0] =>)<br/> 
[bs_facebook_id] => Array ([0] =>)<br/> 
[_edit_last] => Array ([0] => 7)<br/> 
[_edit_lock] => Array ([0] => 1369170429:3)<br/> 
)<br/> 
<br/> 

如何打印网站(bs_website),twitter(bs_twitter),facebook(bs_facebook)?我在论坛中尝试了一些帮助,但只显示了“数组”。

提前致谢。

1 个答案:

答案 0 :(得分:2)

你试过这个吗?

<?php $meta_values = get_post_meta($post_id, $key, $single); ?>

此处有更多信息http://codex.wordpress.org/Function_Reference/get_post_meta