• Hi folks, I’ve created a custom post type using the CPT UI plugin, and I’m wondering if it’s possible for custom posts to belong to multiple different post type categories. Basically, I want to show the same information in a couple of different ways using different templates.

Viewing 1 replies (of 1 total)
  • Yes please check this,
    here these are custom post types.
    array( 'wuelfrath' , 'mettmann', 'haan', 'neanderland' )
    And
    these are multiple categories in which they are coming,
    'category_name' => array( 'kurz-notiert-neanderland' , 'kurz-notiert-mettmann', 'kurz-notiert-haan', 'kurz-notiert-wuelfrath' )

    <?php
    
    $the_query = new WP_Query(
    	array(
    		'post_type' => array( 'wuelfrath' , 'mettmann', 'haan', 'neanderland' ),
    		'posts_per_page' => 5,
    		'category_name' => array( 'kurz-notiert-neanderland' , 'kurz-notiert-mettmann', 'kurz-notiert-haan', 'kurz-notiert-wuelfrath' )
    	)
    );
    ?>
    
    <?php if ( $the_query->have_posts() ) : ?>
    
    	<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
    	<!-- your code here -->
    	<?php endwhile; ?>
    
    	<?php wp_reset_postdata(); ?>
    <?php endif; ?>

    Let me know if this is what you are trying to achieve.

    Regards,
    Haisum

Viewing 1 replies (of 1 total)
  • The topic ‘Custom post types in more than one category?’ is closed to new replies.