4

I have been experiencing 404 errors in my Google webmaster tools reports, caused by Custom Post Type (CPT) feed URLs.

I would like to completely deactivate the CPT feed URLs, so that the 404 errors don't appear anymore in my Google webmaster tools reports. In other words, I'd like to fix all these errors at once by deactivating the functionality that causes them.

2
  • If the URL is not valid and it doesn't exist in your webiste, 404 is the correct status and you should ignore the error in GWT.
    – cybmeta
    Apr 22 '15 at 13:40
  • but, why does the post contain this link to a not working URL? no other website does this to me and I do use CTP.
    – dmtnexer
    Apr 23 '15 at 13:04
1

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' );
1

After some digging, we have noticed that a CPT must enable archives

'has_archive' => true

Must be set for the feed to function - otherwise you get a 404 error

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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