Post type archive page not working

Given the standard registration, you should have the following:

  • A post type with the name ‘recipe’
  • A recipe post archive at example.com/recipe/
  • Recipe posts with urls that take the form example.com/recipe/helloworldrecipe/
  • A template archive-recipe.php
  • A template single-recipe.php

However, I see this in your registration code:

'rewrite' => array('slug' => ''),

This suggests what you’re trying to do is remove the ‘recipe’ prefix from recipe URLs. The result of this is that your recipe post archive is now:

site URL + ''

Which is already taken by the homepage, so your post archive is impossible to get to.

On top of this, it doesn’t actually do what you think it does. You can’t change a custom post type to not have the ‘/recipe/’ part in its URLs using the register_post_type rewrite parameters alone. You need to make other changes, which also introduce potentially site breaking bugs.

For example, if you have a page called ‘pumpkin’ and a recipe called ‘pumpkin’ how is WordPress to know which to load when visiting example.com/pumpkin ? It doesn’t, so it’ll go for whichever rewrite rule it finds first.

So if you have a recipe for pie, but there’s no page called pie, and it looks for the page and doesn’t find it, you dont get the recipe, you get a 404.

So I would strongly advise you abandon your attempt. it makes your URLs make less sense, and despite the nonsense SEO “experts” say, it’s more likely to harm, not help your search engine rankings if it does anything at all ( it very likely does absolutely nothing to help you ).

So remove the rewrite parameter, and resave your permalinks

Update

After you posted this link:

http://seemynewwebsite.com/g2bm/recipecategory/appetizers/

It is now clear that you’re loading a taxonomy and expecting a post type archive. A taxonomy is not a post type, as you can see here, they do not share the same fallbacks:

enter image description here

What’s more it doesn’t make sense that they would. For example, which post type archive template would be used in these scenarios:

  • A taxonomy that contains 2 types of post type, people and locations. Would it fall back to archive-location.php or archive-people.php?
  • A user taxonomy, referring to users, not posts

So instead, use a taxonomy template for your taxonomy, not a post type archive template. In this case taxonomy-recipecategry.php

Leave a Comment