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

What is the best way to disable feeds per post type but keep has_archive enabled?

share|improve this question
up vote 1 down vote accepted

I ran into this issue today. I don't know if it's the best way, but here's how I solved it (with has_archive still set to true, of course):

// First we remove WP default feed actions
// If we stop here, feeds would be disabled altogether
remove_action('do_feed_rdf', 'do_feed_rdf', 10, 1);
remove_action('do_feed_rss', 'do_feed_rss', 10, 1);
remove_action('do_feed_rss2', 'do_feed_rss2', 10, 1);
remove_action('do_feed_atom', 'do_feed_atom', 10, 1);

// Now we add our own actions, which point to our own feed function
add_action('do_feed_rdf', 'my_do_feed', 10, 1);
add_action('do_feed_rss', 'my_do_feed', 10, 1);
add_action('do_feed_rss2', 'my_do_feed', 10, 1);
add_action('do_feed_atom', 'my_do_feed', 10, 1);

// Finally, we do the post type check, and generate feeds conditionally
function my_do_feed() {
    global $wp_query;
    $no_feed = array('cpt_1', 'cpt_2');
    if(in_array($wp_query->query_vars['post_type'], $no_feed)) {
        wp_die(__('This is not a valid feed address.', 'textdomain'));
    else {

Please note that this will cause all feeds to generate as RSS 2.0, when they do generate, but you get general idea.

share|improve this answer
Thanks @tbuteler! – mattrepublic Feb 13 '12 at 23:28

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.