the taxonomy is only TAGS, no categories,
You mean the UI is similar to how tags are, where you’re typing them in instead of having checkboxes? If so, then you need to make the taxonomy hierarchical. There should be a dropdown that you can set to true.
the archive uses archive.php instead of name-archive.php
The template hierarchy would be archive-post-type-slug.php, not post-type-slug-archive.php.
For the archive url, have you been trying http://www.myddomain.com/post-type-slug/ ?
Thanks for the reply.
Did some more reading on this and I have now added archive-post-type-slug (in my case it’s archive-team.php).
Visiting the category (via the admin > custom post type name in left menu > categories > view category), still just takes me to the archive.php template with the ‘Sorry, no posts matched your criteria’.
Has Archive set to True in the settings.
It’s like WP is ignoring the archive-team.php template.
I feel like I am missing something obvious. Do I need a specific query_posts in the archive-team.php or anything added to functions.php ?
Thanks for your speedy reply – much appreciated.
Visiting the category (via the admin > custom post type name in left menu > categories > view category), still just takes me to the archive.php template with the ‘Sorry, no posts matched your criteria’.
Aha. That means you’re visiting a category archive, and if you don’t have a category.php file, or something more specific, it falls back to archive.php. WordPress doesn’t automatically add custom post types to category and tag archives, leaving it up to users to do so. See https://docs.pluginize.com/article/17-post-types-in-category-tag-archives for more information on how.
That also covers the rest of the details at the moment, really. A case of visiting category term archives instead of post type archives.
Thanks,
That’s now working, using archive.php
but still not working using archive-team.php (my custom post type slug)
however it does work using the category ID, in my case category-32.php
Thanks for your help.
Just to confirm a couple things. Are you visiting http://www.mysite.com/team/ to check for the post type archive? Also, do you by chance have a category of “team” that has a matching slug to the post type? Possible you have two different archive types “fighting” for the same url.
The correct page can be seen on both
/category/team/
and /team/
if the address is entered in the browser. But the link we are using in the menu is just the team category link in Appearance > Menus. Using this link, the archive is either archive.php or category-32.php (when that file is added as a template).
with category-32.php removed and archive-team.php added, the page uses archive.php
Resaved the permalinks, no effect.
Can you provide all the actual frontend links to the site in question? I can provide an email if you wish to keep them off the forum.
I’m still pretty sure you’re encountering different archive types based on the behavior you’re describing.
For what it may be worth, we don’t have any direct hand in this topic with CPTUI, we just get the post types/taxonomies registered and WordPress core would be handling the rest, including template selection based on the query being made.