• Resolved David Foreman

    (@davros20)


    Hi.

    Great plugin.

    However, having some problems getting custom post archives to work.

    Added a custom post type, all fine.

    Added a custom taxonomy and assigned to post type, all fine.

    When editing the custom post, the taxonomy is only TAGS, no categories, and the archive uses archive.php instead of name-archive.php AND it shows no posts (even though it should loop through, we just get the default ‘No posts matched… etc.)

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    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/ ?

    Thread Starter David Foreman

    (@davros20)

    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.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    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.

    Thread Starter David Foreman

    (@davros20)

    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.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    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.

    Thread Starter David Foreman

    (@davros20)

    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.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    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.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Custom Post Archives not working’ is closed to new replies.