编辑:使用get\\u post\\u meta()返回一个未序列化的数组,re:post from Oleg Butuzov。谢谢!-我更新了代码示例。
数组的输出是序列化的,必须先取消序列化,然后才能使用php访问信息。
在得到this post 我能够使用unserialize();访问uri。
<?php
//grabs the array with the meta fields of podPress for a particular post or page.
$pp_array = get_post_meta(get_the_ID(), \'_podPressMedia\', true);
$pp_array = $pp_array[0];
?>
<a href="<?php echo esc_attr($pp_array["URI"]) ?>" title="<?php echo esc_attr($pp_array["title"]);?>.mp3">Download</a>
对于那些好奇的人,这里是$pp\\U数组的结果。
第一步:
$pp_array = get_post_meta(get_the_ID(), \'_podPressMedia\', true);
var_dump($pp_array);
RETURNS
array(1) { [0]=> array(10) { ["URI"]=> string(85) "http://www.writingexcuses.com/wp-content/uploads/Writing_Excuses_8_1_Microcasting.mp3" ["title"]=> string(33) "Writing Excuses 8.1: Microcasting" ["type"]=> string(9) "audio_mp3" ["size"]=> int(12759440) ["duration"]=> string(5) "17:43" ["previewImage"]=> string(86) "http://legacieslost.com/writing/wp-content/plugins/podpress/images/vpreview_center.png" ["dimensionW"]=> int(0) ["dimensionH"]=> int(0) ["rss"]=> string(2) "on" ["atom"]=> string(2) "on" } } - See more at: http://www.writingexcuses.com/season-archives/izzy-detective/#sthash.jr9uR8xx.dpuf
第2步:
$pp_array = $pp_array[0];
var_dump($pp_array);
RETURNS
array(10) { ["URI"]=> string(85) "http://www.writingexcuses.com/wp-content/uploads/Writing_Excuses_8_1_Microcasting.mp3" ["title"]=> string(33) "Writing Excuses 8.1: Microcasting" ["type"]=> string(9) "audio_mp3" ["size"]=> int(12759440) ["duration"]=> string(5) "17:43" ["previewImage"]=> string(86) "http://legacieslost.com/writing/wp-content/plugins/podpress/images/vpreview_center.png" ["dimensionW"]=> int(0) ["dimensionH"]=> int(0) ["rss"]=> string(2) "on" ["atom"]=> string(2) "on" } - See more at: http://www.writingexcuses.com/season-archives/izzy-detective/#sthash.iiQ43LEp.dpuf
步骤3:
<p><?php echo $pp_array["URI"];?></p>
RETURNS
http://www.writingexcuses.com/wp-content/uploads/Writing_Excuses_8_1_Microcasting.mp3