disable /feed/ for custom post type

If you dive into how this works, you end up at set_props. At the bottom of that function you see that setting rewrite' => array('feeds' => false) will be interpreted as ‘no rewriting’, meaning the default will be used. Also, if you have not set the has_archive argument WP will not know what to fill the feed with. This is what leads to your 404’s.

That said, what you need is a function that intercepts queries for \feed\ before they lead to a 404. After all, you can’t prevent people typing that url in their browser window, even if there would be a method to stop WP from generating it. So I’d do a check like this:

add_action ('template_redirect','wpse402292_redirect_feed');
function wpse402292_redirect_feed() {
  if (is_feed (array ('post','your-custom-post-type-name')))
     wp_redirect( home_url( '' ) ); // or somewhere else
  }

Leave a Comment