How to disable a Custom Post Type Feed?

I’m also getting an error similar to that. The feed links get generated and put into the and that is where your 404 error is coming from.

Here’s some code to disable feeds for a custom post type. https://gist.github.com/jaredatch/8610187#file-gistfile1-php

<?php
/**
 * Disable the "foo" custom post type feed
 *
 * @since 1.0.0
 * @param object $query
 */
function ja_disable_cpt_feed( $query ) {
    if ( $query->is_feed() && in_array( 'foo', (array) $query->get( 'post_type' ) ) ) {
        die( 'Feed disabled' );
    }
}
add_action( 'pre_get_posts', 'ja_disable_cpt_feed' );

Leave a Comment