I am focusing on a Wordpress theme, that was working last I check and it has since stopped. It can be something little but it is driving me nuts at this time.

I am going for a youtube username and getting the most recent video and embedding in to the page. Appears to become really quite simple, however i might be attacking it wrong.

Here's my code(any suggestions?):

                        <?php // Get YOUTUBE FEED
                    include_once(ABSPATH . WPINC . '/feed.php');

                    // Get a SimplePie feed object from the specified feed source. - YOUTUBE FEED ADDRESS
                    $youtube = fetch_feed('http://gdata.youtube.com/feeds/api/users/USERNAME/uploads');
                    if (!is_wp_error( $youtube ) ) { // Checks that the object is created correctly
                        // Figure out how many total items there are, but limit it to 1.
                        $maxitemsy = $youtube->get_item_quantity(1);

                        // Build an array of all the items, starting with element 0 (first element).
                        $rss_itemsy = $youtube->get_items(0, $maxitemsy);
                        <?php if ($maxitemsy == 0) echo '<li>No Video? Check out our <a href="http://www.youtube.com/USERNAME" >YouTube Channel</a></li>';
                            // Loop through each feed item and display each item as a hyperlink.
                            foreach ( $rss_itemsy as $item ) {
                            $link = $item->get_item_tags('http://search.yahoo.com/mrss/', 'player');
                            $useThis = $link[0]['attribs']['']['url'];
                                <object style="height: 172.5px; width: 230px">
                                    <param name="movie" value="http://www.youtube.com/v/<?php echo getYTid($useThis);?>">
                                    <param name="allowFullScreen" value="true">
                                    <param name="allowScriptAccess" value="always">
                                    <embed src="http://www.youtube.com/v/<?php echo getYTid($useThis);?>" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="230" height="172.5">
                                <?php echo $item->get_content();?>
                        <?php } ?>

Anyways, I keep obtaining the "No video, take a look at our..." output rather than the youtube embed (that was turning up before).


Perhaps you have attempted a var_dump of $youtube and $maxitemsy? I am speculating that something went wrong using the fetch_feed call and ath causes your $maxitemsy to become either or undefined.