Support » Plugin: WordPress RSS Shortcode » [Plugin: WordPress RSS Shortcode] Limit RSS Feed Quantity

  • Resolved InHouse

    (@inhouse)


    Hi, I’m using the WordPress RSS Shortcode plugin and I am wondering how I can limit the quantity of posts that come in. So far I don’t see this option and I’ve googled how to do modify the code myself with no luck. Thanks in advance!

    This is the code so far:

    function rsstag($atts) {
    	$atts = shortcode_atts(array(
    		'url' => get_bloginfo('rss2_url'),
    		'show_author' => 0,
    		'show_date' => 1,
    		'show_summary' => 0
    	), $atts);
    	//var_dump($atts);
    	ob_start();
    	wp_widget_rss_output($atts['url'], $atts);
    	$rss = ob_get_contents();
    	ob_end_clean();
    	return $rss;
    }
    add_shortcode('rsstag', 'rsstag');

    http://wordpress.org/extend/plugins/wordpress-rss-shortcode/

Viewing 6 replies - 1 through 6 (of 6 total)
  • This RSS looked great as you could have date as option but I also need to set a limit!

    Hope to hear an answer soon.

    The plugin from yoast.com has this function. But not the ability to show author or date.
    http://wordpress.org/extend/plugins/rss-shortcode/

    I modified it for my own use so I could change the list format to just add custom delimiters instead, in this case commas. Furthermore the ability to skip some of the posts, e.g. to be able to just show post 6-10.

    Let me know if this extension is to any use for you, I’d be happy to share it.

    Regards, Carl

    Hey guys, a couple things about this that I have found.

    1. To limit item entries, the code should be changed to this:

    function rsstag($atts) {
    	$atts = shortcode_atts(array(
    		'url' => get_bloginfo('rss2_url'),
                    'items' => '5',
    		'show_author' => 0,
    		'show_date' => 1,
    		'show_summary' => 0
    	), $atts);
    	//var_dump($atts);
    	ob_start();
    	wp_widget_rss_output($atts['url'], $atts);
    	$rss = ob_get_contents();
    	ob_end_clean();
    	return $rss;
    }
    add_shortcode('rsstag', 'rsstag');

    This defaults to 5 entries displayed, and will give you the ability to put items=# in the shortcode to put a manual limit of entries displayed.

    2. The URL must have AMPERSANDS encoded to %26 otherwise you may not get the correct feed.

    Cheers, hope that helps.

    One other thing to note, the URL may note work if you put the comma delimiter at the end without a space.

    Example:
    WRONG [rsstag url=http://example.com, items=7]
    CORRECT [rsstag url=http://example.com , items=7]

    Right on, thanks a lot scamartist26. That works perfectly!

    I may have been too speedy with my response here, LOL.

    My code is sloppy, there should not be the single quotes around the integer after the items key. Like so

    'items' => 5,

    It will still work, but is not best practice.

    Also, the shortcode does not need , delimiters, the documentation led me wrong. Those can be left out all together.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Plugin: WordPress RSS Shortcode] Limit RSS Feed Quantity’ is closed to new replies.