• Hey All

    I have been searching and searching and cannot seem to find a working answer. I am trying to show a specific category of a custom post type. Here is to code I am working with:

    <?php $args = array( 'post_type' => 'roster', 'posts_per_page' => 30, 'orderby' => desc );
    		$loop = new WP_Query( $args );
    		while ( $loop->have_posts() ) : $loop->the_post(); ?>
    		<h2 class="member-name"><?php the_title(); ?></h2>
        <div class="member-description">
    		<?php the_post_thumbnail('thumbnail');?>
    		<?php the_content(); ?>
        </div>
    		<?php endwhile; ?>

    What do I need to insert to call the specific category or to filter out the other categories?

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Something like this:

    $args =	array('showposts'=>25, 'category'=>'mycat', 'post_type'=>'mytype');
    $query = new WP_Query($args);
    Thread Starter Chris

    (@lamordnt)

    Hmmmm…. thank you for your help. It does not seem to be working however. Here is what I am now trying but it just shows the posts from all the cateogries:

    <?php $args =	array('showposts'=>25, 'category' => 'former-members' ,'post_type'=>'roster');
    $query = new WP_Query($args);
    		while ( $query->have_posts() ) : $query->the_post(); ?>
    		<h2 class="member-name"><?php the_title(); ?></h2>
           <div class="member-description">
    		<?php the_post_thumbnail('thumbnail');?>
    		<?php the_content(); ?>
        </div>
    
    		<?php endwhile; ?>

    And suggestions?

    So if you need to filter out a specific term, from taxonomy also add tax query like:

    tax_query=>array('field'=>'id', 'terms'=>'12,16', 'operator'=>'IN')

    but if tour taxonomy is the built-in category taxonomy just add:

    category__in=>array(12,16)

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show Specific Category of Custom Post Type’ is closed to new replies.