Get all posts in RSS

I’m wondering how/if I can access more than the most recent X posts defined in the wordpress settings. I’ve seen plugins that migrate all blog content through RSS, haven’t poked around to see their methods.

Basically I manage a couple hundred WordPress blogs, and I’m building a newsletter generator for my clients. They want to be able to select a few posts and have the excerpts appear in the newsletter body. The sites are spread across multiple servers and the newsletter generator is being built on top of our CRM, so direct database queries would be difficult. RSS would be the cleanest, but I can’t seem to figure out how to access more than 10 at a time (when 10 is set in the admin).

Read More

Any ideas?

Related posts

Leave a Reply

7 comments

  1. A way to get your posts is to call the different pages of the rss feed in your newsletter generator. It’s a safe approach that doesn’t require to update your various WordPress installations:

    yourwebsite.com/feed -> get last 10 posts

    yourwebsite.com/feed/?paged=2 -> get next 10 posts

    And so on.

  2. Unfortunately, what you’re trying to do is generally frowned upon in most communities. What I hear you asking for is:

    • A way to remotely retrieve more than the default number of (recent posts)
    • Possibly retrieve all published posts for a site
    • Without having any direct interaction with the site itself (using RSS)

    This is a practice commonly used to scrape content from blogs and republish it without the permission of the original author. That’s why I say it’s generally frowned upon. Most blog authors put a lot of time and energy into developing great content, so making it easy for a third party to leverage their hard work to add SEO credit to their own site is … well … sleezy.

    That said, I will assume for the moment that you have legitimate reasons for scraping content from over 700 sites. In that case, I would recommend a separate, programatic method – not RSS. If you have legitimate login information for all of these sites (i.e. they are your sites and not someone else’s) you can use WordPress built-in XML-RPC features to fetch the content.

    Use the built-in XML-RPC library to pass a request to metaWeblog.getRecentPosts specifying the ID of the blog (usually 0 for single sites, but could be different in multi-site), your WordPress username, your WordPress password, and the number of posts to fetch (set this to -1 to receive them all).

    The other site will respond with (a rather large) XML file containing the content which you can do with what you want. This can all happen behind the scenes, and the metaWeblog.getRecentPosts request will give you much more information than an RSS feed (including custom fields, which might be important to you).

  3. If memory serves, passing -1 as the number of posts has the same effect. Not entirely sure how it gets tossed into a URL, though.

    As an aside, if you’re really into having 700+ sites, consider having a cron that svn updates or git pulls from a stable branch, from a private repository on a daily basis… Combined with a daily http call to wp-admin/upgrade.php. It’ll save you a lot of hassles when upgrading or tweaking your sites — in that it’ll get done automatically.

  4. While not “all posts”, I’d argue that a limit param is much more useful.

    I would recommend directly filtering the “posts_per_rss” option as such:

    add_filter( 'option_posts_per_rss', 'my_posts_per_rss' );
    function my_posts_per_rss( $option ) {
        if( isset( $_GET['limit'] ) ) {
            return (int) $_GET['limit'] ?: $option;
        }
        return $option;
    }
    

    The feed could then be accessed like so:
    http://example.org/category/acme/feed/?limit=999

  5. If you go to Settings > Reading > and change the value in the “Syndication feeds show the most recent” to a number that suits you, it will show up to the number of feeds you input.