Support » Fixing WordPress » SimplePie mRSS – Get at media:content URL?

  • Resolved Drew Baker


    Hi Guys,
    I’m trying to pull in content from a mRSS feed. This is an example of the mRSS item:

    	<title><![CDATA[Title Example]]></title>
    	<br /><img src="" />]]></description>
    	<pubDate>Fri, 1 Dec 2009 00:42:21 +0000</pubDate>
    	<enclosure url="" type="video/quicktime" length="5319922"/>
    	<media:content url="" fileSize="5319922" type="video/quicktime" height="270" width="480"/>
    	<media:thumbnail url="" height="480" width="640"/>
    	<media:thumbnail url="" height="135" width="180"/>
    	<media:credit role="client">Client</media:credit>
    	<media:credit role="director">John Doe</media:credit>
    	<media:credit role="agency" >Agency Example</media:credit>
    	<media:credit role="production company">Example Production Company</media:credit>
    	<media:credit role="award winner">Example Award</media:credit>

    My question is, how do I get to the media:content url? I’m using this code, but it doesn’t work:

    <?php // Get RSS Feed(s)
    include_once(ABSPATH . WPINC . '/feed.php');
    // Get a SimplePie feed object from the specified feed source.
    $rss = fetch_feed('');
    if (!is_wp_error( $rss ) ) : // Checks that the object is created correctly
        // Figure out how many total items there are, but limit it to 5.
        $maxitems = $rss->get_item_quantity(5); 
        // Build an array of all the items, starting with element 0 (first element).
        $rss_items = $rss->get_items(0, $maxitems);
    <?php if ($maxitems == 0) echo '<li>No items.</li>';
    // Loop through each feed item and display each item as a hyperlink.
        foreach ( $rss_items as $item ) : ?>
    	<a href="<?php echo $media->content->attributes()->url; ?>">Test</a>
    <?php endforeach; ?>

    I get this error:

    Fatal error: Call to a member function attributes() on a non-object…

    I know I’m doing doing this line wrong:

    What is the correct syntax?


Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘SimplePie mRSS – Get at media:content URL?’ is closed to new replies.