WordPress.org

Ready to get started?Download WordPress

Forums

WP RSS Aggregator
[resolved] Limit Results (24 posts)

  1. gfa202
    Member
    Posted 2 years ago #

    Great plugin! Works like a charm.

    Was curious if there was a clean way to limit the results? I've been adding rss feeds to a widget on sidebar using php and the results are long! Any way to limit it to, lets say, last 50 items or so? Or maybe do you plan on adding pagination?

    Thanks!

    http://wordpress.org/extend/plugins/wp-rss-aggregator/

  2. jeangalea
    Member
    Plugin Author

    Posted 2 years ago #

    This is something I can consider for the next update. Rather than pagination I think I would add a limit, say 10 items for each section (today, yesterday, 2 days ago etc.).

    Hopefully that would help you keep things tidier.

  3. adga
    Member
    Posted 2 years ago #

    I have just installed the Aggregator and it does just what I want and is simple to use but I have the same issue as gfa202. So I am pleased to see you intend to address this. It would be better from my point of view if there was a way of setting the numbers of entries displayed in each section.

    Thanks.

  4. TribalDancer
    Member
    Posted 2 years ago #

    I am adding my "yes please" to this!

  5. jeangalea
    Member
    Plugin Author

    Posted 2 years ago #

    Thanks all feedback appreciated, I will gather all requests and work on them for the next release.

  6. ninanoespelho
    Member
    Posted 2 years ago #

    Is that possible to show the images (thumbnails) and a beginning of the original posts with the plugin? I'm trying to create a content aggregator, and i'd like to use this plugin.

  7. jeangalea
    Member
    Plugin Author

    Posted 2 years ago #

    It would be possible with modifications, I can't guarantee that I'll be adding this feature though.

  8. jennybeaumont
    Member
    Posted 2 years ago #

    @ninanoespelho - just posted info on how to add images :)
    best,
    -jennyb

  9. stuartirene
    Member
    Posted 2 years ago #

    Hi there,

    I've read Jenny's solution on adding thumbnail but would like to know in specific location of adding those codes to wp-rss-aggregator.php.

    I'm not so sure of where to insert the following codes to wp-rss-aggregator.php?
    1) preg_match_all('/<img([^>]*)>/i', $item->get_content(), $matches);
    // Get all of the image tags

    2) $all_images = $matches[0];

    Could anyone please guide me on these? Many thanks.

  10. adinb
    Member
    Posted 2 years ago #

    a field to limit the number of items fetched for a particular feed would be nice -- and/or a date limit field (i.e. nothing older than a month)

    great little plugin!

  11. Rose Pajaroja
    Member
    Posted 2 years ago #

    hi! I am really new here, stupid than a newbie. :D I need some help.

    1. How do I limit the feeds to just the most recent? Like maybe 5 or 6 items?
    2. How to put the thumbnails?

    I am actually working on it, with de.pinque WP theme. I am trying to put it in my sidebar. Thanks a million. :)

  12. jeangalea
    Member
    Plugin Author

    Posted 2 years ago #

    Coming in the new version :)

  13. Rose Pajaroja
    Member
    Posted 2 years ago #

    Wow! Thanks. :) Looking forward to it. :) I wish I could also show the thumbnails. ;)

  14. jennybeaumont
    Member
    Posted 2 years ago #

    Desperately wanting to limit number of posts in feed! :))))))

    And updated my add thumbnail explanation here for those in need. Hope it helps.

    cheers,
    -jennyb

  15. jennybeaumont
    Member
    Posted 2 years ago #

    Ok folks, I couldn't wait and am very happy to announce that I have a solution for us :D

    Modifiy the shortcode declartion in wp-rss-aggregator.php at line 223, by replacing

    // Register a new shortcode
        add_shortcode( 'wp_rss_aggregator', 'wprss_shortcode');
    
        function wprss_shortcode( $atts ) {
            if ( !empty ($atts) ) {
                foreach ( $atts as $key => &$val ) {
                    $val = html_entity_decode($val);
                }
            }
            wp_rss_aggregator( $atts );
        }

    with

    // Register a new shortcode
        add_shortcode( 'wp_rss_aggregator', 'wprss_shortcode');
    
        function wprss_shortcode( $atts ) {
    	extract( shortcode_atts( array(
    		'limit' => '20',
    	), $atts ) );
    
            if ( !empty ($atts) ) {
                foreach ( $atts as $key => &$val ) {
                    $val = html_entity_decode($val);
                }
            }
            wp_rss_aggregator( $atts );
        }

    This will add the "limit" variable with a default of 20.

    Then, before the (or each of the) foreach statements replace:

    `foreach ( $items_today as $item ) {

    echo $link_before . '<a class="colorbox" href="' . $item->get_permalink() .'">'. $item->get_title(). ' '. '</a>';
    echo '<br><span class="feed-source">Source: '.$item->get_feed()->get_title()/* . ' | ' . $item->get_date('l jS F').''*/ . '</span>';
    echo $link_after;

    }`

    with

    $feedlimit = $limit; //call variable
    foreach ( $items_today as $item ) {
    $counter++; //add counter
    echo $link_before . '<a class="colorbox" href="' . $item->get_permalink() .'">'. $item->get_title(). ' '. '</a>';
    echo '<br><span class="feed-source">Source: '.$item->get_feed()->get_title()/* . ' | ' . $item->get_date('l jS F').''*/ . '</span>';
    echo $link_after;
    if($counter >= $feedlimit) break; //break if count is met
                }

    Then, in your shortcode simply add limit=X, where X is the number of posts you want to show. Et voilĂ  ! works on my end, let me know how it works for you!

    -jennyb

  16. OC2PS
    Member
    Posted 2 years ago #

    This is the only working aggregator plugin, so I do hope that jeangalea implements this in the next version, and that the next version comes out soon.

    This is what I think:
    1. The site owner should be able to configure number of items/section. e.g. 10 per section
    2. The site owner should be able to configure how many sections...I, for instance, need only Today.
    The above 2 are absolutely required functions yesterday.

    Once we have the above 2, I hope jeangalea also looks at
    3. The site owner should be able to configure the maximum number of items from each individual feed that are allowed. e.g. Max 3 from NYTimes, max 1 from NBC, max 3 from BBC, etc

  17. jeangalea
    Member
    Plugin Author

    Posted 2 years ago #

    Thanks for your feedback guys, I can't wait to get working on the next version, I just haven't found the time to do it, but promise to do my best to have another version out soon.

  18. jennybeaumont
    Member
    Posted 2 years ago #

    nobody noticed the solution i posted above? :)
    -jennyb

  19. Miz.Michele
    Member
    Posted 1 year ago #

    Jenny I installed the plug-in today and want to implement your fix.

    I understand the first part of replacing the short code.

    Can you help me with the 2nd part of the foreach - I don't quite get it. I need more "dummy" instructions. I see 2 foreach statements on line 262 and 284 after I added the changes to the shortcode.

    Can you go over what I need to do?

  20. jennybeaumont
    Member
    Posted 1 year ago #

    Hi Miz.Michele,

    Ok, I see why this is confusing. In my modified version of the plugin, I've combined all the foreach statements into one, thus deleting the whole breakdown into sections by date.

    Now that I'm looking at the original code more closely, I realize that my "simple" instructions are not so simple.

    The first foreach that starts on line 280 foreach ( $items as $item ): is used just to define the names and date ranges of each statement. Skip down to the next one at line 299 that begins foreach ( $items_today as $item ) {

    That's what interests us.

    Ok, now that we know where we are, let me start over. At this point you should be able to see the series of 4 loops, embedded within an "if" statement :

    if ( !empty( $items_today ) ) {
    echo $date_before . 'Today' . $date_after;
    echo $links_before;
    foreach ( $items_today as $item ) {
    if ( !empty( $items_yesterday ) ) {
    echo $date_before . 'Yesterday' . $date_after;
    echo $links_before;
    foreach ( $items_yesterday as $item ) {
    if ( !empty( $items_two_days_ago ) ) {
    echo $date_before . '2 days ago' . $date_after;
    echo $links_before;
    foreach ( $items_two_days_ago as $item ) {
    if ( !empty( $items_older ) ) {
    echo $date_before . 'More than 2 days ago' . $date_after;
    echo $links_before;
    foreach ( $items_older as $item ) {

    BEFORE the foreach line for all 4, ADD $feedlimit = $limit; //call variable
    AFTER the foreach line for all 4, ADD $counter++; //add counter

    At the end of each of the 4, AFTER the line echo $link_after;, ADD if($counter >= $feedlimit) break; //break if count is met

    HOWEVER, keep in mind that with this set up, there is only one variable, which means each section has to have the same limit. You could only define some of the sections, or you could add variables, like LIMIT2days, LIMITyesterday, etc.

    Or, like me, you could get rid of the sections and have one solid feed. Up to you :)

    Hope that helps!
    -jennyb

  21. Miz.Michele
    Member
    Posted 1 year ago #

    Thank you very much. I am going to play around with it because I am trying to have my output come out in blocks. At least now, I can control the length. Thanks again.

  22. Rajesh D
    Member
    Posted 1 year ago #

    Hi Jenny, i need a help from you.

    As i want code for same output for the WP loop to display list of post in the same manner how WP RSS Aggregator display. Like

    Today
    <list of all today's post>

    Yesterday
    <list of all Yesterday's post>

    2 days ago
    <list of all 2 days ago post>

    More than 2 days ago
    <list of all post More than 2 days ago with Limit>

    Thanks and awaiting for your reply.

  23. jennybeaumont
    Member
    Posted 1 year ago #

    Hi Rajesh,

    You should probably create a new post for your question in the appropriate forum as this thread relates only to the WP RSS Aggregator (of which I am NOT the author btw).

    Here's a jump to get you started tho :
    http://codex.wordpress.org/The_Loop

    cheers,
    -jennyb

  24. Rajesh D
    Member
    Posted 1 year ago #

    Thanx Jenny for reply but do u have solution for my problem. i will start new post.

    Regards
    Rajesh

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic