Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    Your CPT needs to explicitly associate with the category taxonomy when the CPT is registered, or add the relationship with register_taxonomy_for_object_type().

    When category requests are made, you likely need to add your CPT to the “post_type” query var through the “pre_get_posts” action. Chances are the default is only “post”. Your callback should verify the query is the main query and that it’s a category request. If so, do something similar to $query->set('post_type'=>array('post', 'my_CPT'));

    I use https://ww.wp.xz.cn/plugins/custom-post-type-archives/
    As it says, WordPress 3.1 improved how custom types work, but this plugin lets you choose which ones to show and what slug to use for them.
    So you either have your own plugin to create the post types or use a plugin to create it for you. You can put the code to make specific theme templates for those in the plugin or in a child theme. Read about the Template Hierarchy for what to name the template files.
    https://codex.ww.wp.xz.cn/Post_Type_Templates

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Category Template for Custom Post Type posts’ is closed to new replies.