Pulling another WP RSS Feed depreciated?

WordPress 8 posts 2 voices

  1. I have used the following for a while now with no problems, now all of a sudden i’m getting the following error.

    Does WordPress still support this or has it been depreciated?

    Notice: Undefined variable: limit in /var/www/web/wp-content/themes/Page-One-Media-Photo/inc-site/home/contact-footer.php on line 26
    The feed is either empty or unavailable.

    The feed linking in, is another WordPress site and defiantly has an RSS feed.

    Line 26 is ` if ($limit == 0) echo ‘

    The feed is either empty or unavailable.

    ‘;

    The full function...

    get_item_quantity(1); // specify number of items
    $items = $feed->get_items(0, $limit); // create an array of items
    }
    }
    if ($limit == 0) echo ‘

    The feed is either empty or unavailable.

    ‘;
    else foreach ($items as $item) : ?>

    get_title(); ?>

    get_description(), 0, 200); ?>

    <a class="arrow_link" href="get_permalink(); ?>”>Read More

    `

    This always (from what i can find) something that seems to be an after thought via WordPress or has it indeed been depreciated? I remember when i initially set it up that the site will only search for new posts a certain amount of times a day is this correct and perhaps have something to do with it?

  2. Dont know what happened to the above formatting 🙁

    <?php if(function_exists('fetch_feed')) {
    						
    							include_once(ABSPATH . WPINC . '/feed.php');               // include the required file
    							$feed = fetch_feed('http://pageonemedia.co.uk/feed/'); // specify the source feed
    							if( ! is_wp_error( $feed ) ) {
    								$limit = $feed->get_item_quantity(1); // specify number of items
    								$items = $feed->get_items(0, $limit); // create an array of items
    							}
    						}
    						if ($limit == 0) echo '<div>The feed is either empty or unavailable.</div>';
    						else foreach ($items as $item) : ?>
    						
    						
    						<h3 class="section_title sub [ blue medium_spacing ]"><?php echo $item->get_title(); ?></h3>
    						    
    						    <div class="body_copy  [ light ]">
    						    	<?php echo substr($item->get_description(), 0, 200); ?>
    						    <!--body_copy-->
    						    </div>
    												
    						<a class="arrow_link" href="<?php echo $item->get_permalink(); ?>">Read More</a>
    						
    <?php endforeach; ?>
  3. It looks like there might have been a number of issues. I just rewrote it. I hope this works:

    <?php 
    
    if ( ! function_exists( 'fetch_feed' ) ) {
    	include_once( trailingslashit( ABSPATH . WPINC ) . 'feed.php' );
    }
    
    $feed = fetch_feed( 'http://pageonemedia.co.uk/feed/' );
    
    if ( ! is_wp_error( $feed ) ) :
    
    	$limit = $feed->get_item_quantity( 1 );
    	$items = $feed->get_items( 0, $limit );
    
    	if ( 0 == $limit || ! $items ) : ?>
    
    		<div>The feed is either empty or unavailable.</div>
    
    	<?php else :
    
    		foreach ( $items as $item ) : ?>
    
    			<h3 class="section_title sub [ blue medium_spacing ]"><?php echo $item->get_title(); ?></h3>
    
    			<div class="body_copy  [ light ]">
    				<?php echo substr( $item->get_description(), 0, 200 ); ?>
    			</div>
    
    			<a class="arrow_link" href="<?php echo $item->get_permalink(); ?>">Read More</a>
    						
    		<?php endforeach;
    
    	endif;
    
    endif; ?>
  4. Thank you Justin and sorry for the late reply.

    Your code works with every feed just not one the one i need.

    With the feed i need, it just appears blank, no error nothing at all!

    Is this something from this site where the code sits on, or from where i’m getting the feed from as it works with some just not others?

    Unsure how anything else could effect this, turned off plugins on both sites (i have access to them) and still the issue.

    Could it be down to permissions on the site publishing the feed or the site trying to show it?

    I’ve the following running for the cache of the feed, could this effect it?

    /**
     * Setting a new cache time for feeds in WordPress
     */
    function prefix_set_feed_cache_time( $seconds ) {
    	return (int) 600;
    }
    add_filter( 'wp_feed_cache_transient_lifetime' , 'prefix_set_feed_cache_time' );

    Do images, or vimeo files in the posts effect their ability to show elsewhere?

  5. The feed won’t appear if an error is returned when fetching it. There’s nothing you can do about that on your end. It could be any number of issues from the site/feed you’re fetching.

    If you want to see if it’s an error, try this code out:

    <?php 
    
    if ( ! function_exists( 'fetch_feed' ) ) {
    	include_once( trailingslashit( ABSPATH . WPINC ) . 'feed.php' );
    }
    
    $feed = fetch_feed( 'http://pageonemedia.co.uk/feed/' );
    
    if ( is_wp_error( $feed ) ) :
    
    	var_dump( $feed );
    endif;
  6. Thank you Justin that was really helpful.

    It returned this error and i’ve been give access to the site we’re trying to pull the feed from.

    So my next question would be, what does this error mean and how can i fix it…

    object(WP_Error)#5659 (2) { ["errors"]=> array(1) { ["simplepie-error"]=> array(1) { [0]=> string(53) "WP HTTP Error: cURL error 52: Empty reply from server" } } ["error_data"]=> array(0) { } }

    Hosting or something we can fix from within the feed’s theme?

  7. That error seems to be saying the reply you got from the server (where the feed is from) is empty. So, there’s nothing you can do from your end.

    It’s probably something that needs to be fixed on the site where you’re pulling the feed from. The owner would probably need to talk to their Web host. You can always try the usual like disabling all plugins first. That’s the best advice I have on that. This is well outside my area of expertise.

  8. Thanks Justin.

    The feed works when viewing say within Firefox, or Reeder, just not within this method.

    I’ve been given access and tried turning off all the plugins but to no avail.

    Defiantly think its something to do with the hosting, as it was working and now not!