Support » Plugin: WP RSS Aggregator » Limiting feed in template

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author Jean Galea

    (@jeangalea)

    Through the plugin settings panel you can limit the number of feeds displayed.

    Yes but was wondering if there was more code that I could add to php call to limit it less than 1000 that I have it set in settings panel

    Plugin Author Jean Galea

    (@jeangalea)

    No the settings panel is all there is. Can you explain why you’d like to do this so I’ll have a better idea and maybe implement it in the next update?

    Thanks, my site runs a podcast every week and we have over 300+ I want to list on a page which I use your plugin for. On the homepage I only want to show the last 5. So I wanted to use your code above to show only 5 of the latest podcasts

    Plugin Author Jean Galea

    (@jeangalea)

    Ah ok, I got it, I’m noting it down to implement for the next release. Definitely makes sense and we should also have this possible via shortcode.

    Thanks!

    I just made this exact change to the plugin. It only required updating a few lines of code in the /includes/feed-display.php file

    Change Line 173 to:

    $feed_items = wprss_get_feed_items_query( $settings, $args );

    Starting at Line 69, change the wprss_get_feed_items_query function to:

    function wprss_get_feed_items_query( $settings, $args = false ) {
    	// Arguments for the next query to fetch all feed items
    	$posts_per_page = (isset($args['feed_limit']) && $args['feed_limit'] > 0) ? $args['feed_limit'] : $settings['feed_limit'];
    	$feed_items_args = apply_filters(
    							'wprss_display_feed_items_query',
    							array(
    								'post_type'      => 'wprss_feed_item',
    								'posts_per_page' => $posts_per_page,
    								'orderby'        => 'meta_value',
    								'meta_key'       => 'wprss_item_date',
    								'order'          => 'DESC'
    							)
    	);
    
    	// Query to get all feed items for display
    	$feed_items = new WP_Query( $feed_items_args );
    
    	return $feed_items;
    }

    Works for me. Now I can set the limit in the shortcode like this: [wp_rss_aggregator feed_limit=5]. And it will default back to the widget setting if a limit isn’t specified.

    I need just the opposite. I need the settings set at 900 and the code at the top of the page set to 5 not the shortcode

    The above changes to the plugin file would allow you to pass a limit through the shortcode. I use the following code in my template PHP file instead of the line you have in the original post:

    <?php echo do_shortcode(“[wp_rss_aggregator feed_limit=5]”); ?>

    http://codex.wordpress.org/Function_Reference/do_shortcode

    Thanks ill try it soon

    Note: any changes you make to the plugin files will be overwritten when you update the plugin, but it sounds like the plugin author is going to add this in the next version. (Though he may not use the same method I did.)

    Also, be sure to save a back up copy of any files you change, because even a basic PHP error can take down your entire website.

    Works like a charm! Thank you so much, my project is close to completion because of this fix

    Plugin Author Jean Galea

    (@jeangalea)

    This is coming in the next update.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Limiting feed in template’ is closed to new replies.