WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to redirect my visitors to my 404 when they visit any feed of my page. Something like this. I would liek to do this without changing the header URL.

function fb_disable_feed() {

// set_404();

add_action('do_feed', 'fb_disable_feed', 1);
add_action('do_feed_rdf', 'fb_disable_feed', 1);
add_action('do_feed_rss', 'fb_disable_feed', 1);
add_action('do_feed_rss2', 'fb_disable_feed', 1);
add_action('do_feed_atom', 'fb_disable_feed', 1);

Please help!

share|improve this question

There are three simple steps to get what you want:

  1. Hook into 'template_redirect' to act before the feed is displayed.
  2. If it is a feed send a 404 status header and
  3. load the 404 template.

Here is a simple plugin that does it:

<?php # -*- coding: utf-8 -*-
 * Plugin Name: T5 404 Feed
 * Description: Sends a 404 status code for all feeds and loads the <code>404.php</code> template.

add_action( 'template_redirect', 't5_404_feed', 1 );
function t5_404_feed()
    if ( is_feed() )
        status_header( '404' );
        locate_template( array ( '404.php', 'index.php ' ), TRUE, TRUE );

I am not so sure that 404 is the proper status code. 410 (Gone) may fit better.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.