WordPress: How to include a custom field in an array (SmplePie)

WordPress 2.8.4, Simple Pie Plugin 2.2.1

I’m having this:

Read More
<?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')
); ?>

Instead of fifa10 I’d like to have the value of a custom field with the key name-of-game in there.

How can I do this?

Related posts

Leave a Reply

1 comment

  1. You get the value of a WordPress custom field with get_post_meta():

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

    To include it in your function call to SimplePieWP, use string concatenation with . (dot):

    <?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')); ?>