• I declared a custom post type. I can add new, save and display my cpt and it’s meta data. This all works nicely.

    When declaring my cpt I set
    ‘taxonomies’ => array(‘category’),

    I then added some categories manually and assigned specific cpt posts to those categories.

    The categories in this example are all 50 states.

    When I go to https://domain.com/category/rhode-island/ I only get results for regular posts that are in the category, however all cpt’s have been excluded.

    These results are built by the template page archive.php

    All attempts to do archive-cpt-name.php have failed but I am not concerned with this at the moment.

    If I perform a search within the category my cpt’s show so for example https://domain.com/category/rhode-island/?s=a will show all posts and cpt’s with the letter “a”.

    I have been able to search more specifically and pull up just cpt results as well.

    The search results are powered by the search.php template which is an exact duplicate of the archive.php.

    My main question here is what would keep the custom post type posts from showing in archive/category results but allow them to be searched with in that category?

Viewing 2 replies - 1 through 2 (of 2 total)
  • I don’t think custom post types are shown by default. I think you have to define them before your query

    Something like.

    <?php query_posts( array('post_type', => 'your-post-type') ); ?> before your loop

    also keep in mind that you can do multiple post types

    <?php query_posts( array(
    	'post_type' => array('post',
    			'your-post-type-1',
    			'your-post-type-2',
    			'your-post-type-3'
    	) )
    ); ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Post Type Taxonomy Issue’ is closed to new replies.