Posts from Custom Post Type and Custom Post Type Category
-
Hi,
I’m trying to list all the posts within my Custom Post Type (News) that are of a particular custom category (Machine Tools).
I’ve been using the following code
<?php $cust_post_type = get_post_type(); $args = array( 'post_type' => 'news', 'tax_query' => array( array( 'taxonomy' => 'news_cat', 'field' => 'slug', 'terms' => 'machine-tools' ) ) ); $products = new WP_Query( $args ); if( $products->have_posts() ) { while( $products->have_posts() ) { $products->the_post(); ?> <div class="row"> <div class="five columns"> <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('news-thumb'); ?></a> </div> <div class="seven columns"> <h4 style="margin-top:0px;padding-top:0px;"><?php the_title(); ?></h4> <?php the_excerpt(); ?> </div> <hr style="margin: 10px 0 20px 0;" /> </div> <?php } } else { echo 'There are currently no news stories available.'; } ?>
But I’m still unable to get any results through it. Has anybody got any ideas?
- The topic ‘Posts from Custom Post Type and Custom Post Type Category’ is closed to new replies.