How to remove custom post type archive

I have a custom post type called “recipe” with the has_archive parameter set to true. Visiting mysite.com/recipe/ gives a basic archive list of all the recipes posted and a page title of “Recipes”. So far so good.

Now I’m looking to disable that recipe archive page (but keep individual recipe links working). My first thought was to try setting has_archive to false, which sounds like it should do the trick. Nope. The only difference this makes is the page title which for some reason becomes the name of the site. The actual archive is still displayed.

Read More

What is the best way to actually remove that archive completely? Is there a parameter of register_post_type that will achieve this or is it impossible and a case of a custom page template with a redirect in it?

Thanks.

Related posts

1 comment

  1. The has_archive parameter for register_post_type() does exactly what you expect it to do. However, it modifies rewrite rules when set. So, if you change it to false, you’ll need to flush your rewrite rules in order for the archive index display to be removed entirely.

Comments are closed.