Support » Fixing WordPress » Creating an RSS-Feed-only WordPress Site

  • Resolved Raam Dev


    I’m working on a project where I’ll be posting content to a WordPress site via email and then accessing that posted content via RSS. However, I don’t want the content to be publicly accessible on the front-end of WordPress (i.e., web crawlers, web browsers going directly to the post URLs, etc.); the only way of viewing the post content should be via RSS.

    I’m not sure how I should go about this. Should I edit all of the template files in my theme and just remove anything that outputs the post content and title? Or is there a more simple way of doing this via hooks, e.g., using the is_feed() function to check if a feed is loading the post and then return "" if it’s not a feed?

    Any examples would be greatly appreciated. Thank you.

Viewing 1 replies (of 1 total)
  • Just a quick update here for anyone else who might find this thread trying to do something similar.

    You can simply hide the content of all your posts, except for in RSS Feeds, by placing the following in your theme’s functions.php file:

    add_filter( 'the_content', 'exclude_non_feed', 20 );
    function exclude_non_feed( $content ) {
        if ( !is_feed() ) { $content = "<strong>Sorry, this content is only available through a special RSS feed.</strong>"; }
        return $content;

    For my scenario, I wanted to hide basically the entire public-facing site, so I did that by simply adding the following to the top of my theme’s header.php file:

    <?php if ( !is_feed() ) { exit; } ?>

    It’s not optimal, but it does what I need. If anyone can recommend a cleaner way of doing this, I’m all ears! 🙂

Viewing 1 replies (of 1 total)
  • The topic ‘Creating an RSS-Feed-only WordPress Site’ is closed to new replies.