尝试以下操作:
$value = get_post_custom_values( \'banda_postmeta\', $post->ID );
$value = unserialize("$value");
print_r($value);
echo $value[\'social_networks_url\'][\'twitter_url\'];
您的
social_networks_url
为空,请尝试回显这些值,它将回显该值。
echo $value[\'page_builder_settings\']."<br />";
echo $value[\'date_of_birth\']."<br />";
echo $value[\'location\']."<br />";
输出:
array (size=7)
\'social_networks_url\' =>
array (size=9)
\'twitter_url\' => string \'wr\' (length=2)
\'facebook_url\' => string \'\' (length=0)
\'youtube_url\' => string \'\' (length=0)
\'google-plus_url\' => string \'\' (length=0)
\'linkedin_url\' => string \'\' (length=0)
\'instagram_url\' => string \'\' (length=0)
\'dribbble_url\' => string \'\' (length=0)
\'github_url\' => string \'\' (length=0)
\'pinterest_url\' => string \'\' (length=0)
\'page_builder_settings\' => string \'global\' (length=6)
\'date_of_birth\' => string \'1932-10-24\' (length=10)
\'location\' => string \'California <div class="rssfeeds"><img src="http://www.speakingofbusiness.com/wp-content/uploads/2014/12/logo-rss-feed.png" width="12" /><button onclick="myFunction()">RSS</button></div>\' (length=185)
\'ad\' => string \'<a href="http://www.kqzyfj.com/click-5434584-10365698" target="_top"> <img src="http://www.tqlkg.com/image-5434584-10365698" width="120" height="60" alt="www.1and1.com" border="0"/></a>\' (length=185)
\'ad1\' => string \'Hi\' (length=2)
\'ad2\' => string \'Hello\' (length=5)
wr
global
1932-10-24
California www.1and1.com
Hi
Hello
查看我的代码和输出:
$str = \'a:7:{s:19:"social_networks_url";a:9:{s:11:"twitter_url";s:2:"wr";s:12:"facebook_url";s:0:"";s:11:"youtube_url";s:0:"";s:15:"google-plus_url";s:0:"";s:12:"linkedin_url";s:0:"";s:13:"instagram_url";s:0:"";s:12:"dribbble_url";s:0:"";s:10:"github_url";s:0:"";s:13:"pinterest_url";s:0:"";}s:21:"page_builder_settings";s:6:"global";s:13:"date_of_birth";s:10:"1932-10-24";s:8:"location";s:185:"California <div class="rssfeeds"><img src="http://www.speakingofbusiness.com/wp-content/uploads/2014/12/logo-rss-feed.png" width="12" /><button onclick="myFunction()">RSS</button></div>";s:2:"ad";s:185:"<a href="http://www.kqzyfj.com/click-5434584-10365698" target="_top"> <img src="http://www.tqlkg.com/image-5434584-10365698" width="120" height="60" alt="www.1and1.com" border="0"/></a>";s:3:"ad1";s:2:"Hi";s:3:"ad2";s:5:"Hello";}\';
$value = unserialize($str);
echo $value[\'social_networks_url\'][\'twitter_url\']."<br />";
echo $value[\'page_builder_settings\']."<br />";
echo $value[\'date_of_birth\']."<br />";
echo $value[\'location\']."<br />";
echo $value[\'ad\']."<br />";
echo $value[\'ad1\']."<br />";
echo $value[\'ad2\']."<br />";