Wordpress:如何在数组中包含自定义字段(SmplePie)

时间:2009-09-05 07:07:09

标签: wordpress rss simplepie

Wordpress 2.8.4,Simple Pie Plugin 2.2.1

我有这个:

<?php echo SimplePieWP(
array(
   'http://gdata.youtube.com/feeds/base/videos?q=fifa10%20trailer&client=ytapi-youtube-search&alt=rss&v=2'
),
array(
   'items' => '1')
); ?>

而不是fifa10我希望拥有自定义字段的值,其中包含密钥name-of-game

我该怎么做?

1 个答案:

答案 0 :(得分:0)

您可以使用get_post_meta()获得Wordpress自定义字段的值:

get_post_meta($post->ID, 'name-of-game', true)

要将它包含在对SimplePieWP的函数调用中,请使用字符串连接.(点):

<?php echo SimplePieWP(array('http://gdata.youtube.com/feeds/base/videos?q=' .
get_post_meta($post->ID, 'name-of-game', true) .
'%20trailer&client=ytapi-youtube-search&alt=rss&v=2'),array('items' => '1')); ?>