WordPress.org

Forums

How to restrict feed format choice (3 posts)

  1. bmck
    Member
    Posted 8 years ago #

    Strange I can't find a search result for this but...

    I have Mint 2 installed and Feeder tells me that I have subscribers to my RSS, RSS2, Atom, and RDF feeds. I have customised my RSS2 feed which is what I want everyone to be using.

    Do I need to hack wp-feed.php in order to re-direct requests for RSS/ Atom/ RDF to wp-rss2.php for RSS2? Is so, what edit do I make (I'm using WordPres 2.0.7)?

    Cheers, Bruce

  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 8 years ago #

    You could easily hack the thing to provide the feed you want to provide. Look at this bit of code:

    switch ($feed) {
        case 'atom':
            require(ABSPATH . 'wp-atom.php');
            break;
        case 'rdf':
            require(ABSPATH . 'wp-rdf.php');
            break;
        case 'rss':
            require(ABSPATH . 'wp-rss.php');
            break;
        case 'rss2':
            require(ABSPATH . 'wp-rss2.php');
            break;
        case 'comments-rss2':
            require(ABSPATH . 'wp-commentsrss2.php');
            break;
        }

    It's fairly obvious how that works. Just change the first three to use wp-rss2.php instead of what they are currently using. Don't mess with the comments one, it handles feeds for your comments on individual posts..

    Note that this isn't exactly safe, some aggregators may not like you switching formats from what they were expecting like that. But I think most will handle it okay.

    You may also want to look in your theme's header.php file, and remove the lines at the top which advertise your other feeds. They will look similar to this:
    <link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" />

    Just delete the ones for ATOM and RSS1, if they are there, and leave the RSS2 one.

  3. bmck
    Member
    Posted 8 years ago #

    Thanks Otto; I was hoping it would be that simple ;-)

Topic Closed

This topic has been closed to new replies.

About this Topic