Custom Post Types in Archive

Hi guys,

I’m having trouble displaying custom post types inside a category archive.

I have created a Custom Post type named “country” including the following options:
has_archive":"true" "has_archive_string":"" "exclude_from_search":"false" "capability_type":"post" "hierarchical":"false" "rewrite":"true"

I have registered the ctp in init.php:
add_theme_support('post-formats', ['aside', 'gallery', 'link', 'image', 'quote', 'video', 'audio', 'country']);

Posts of the Post Type with categorie “Asia” do not appear on the /category/asia page (Soil active), only regular posts show inside “Asia”. works, and uses the archive-country.php perfectly.

I’m not sure this is a Roots workflow issue, but i’m hoping you guys could help me out.

This is a general question and belongs on or one of its equivalents.

You will need register_taxonomy_for_object_type to make categories accessible for your custom post type and then need to use pre_get_posts to add the custom post type to the category archive query. That should be enough to help you in your search.

You should also read up on custom post types and post formats because they are two different things.

1 Like

This topic was automatically closed after 2 hours. New replies are no longer allowed.