I want to create a listing of custom post types in a particular category. I’ve tried the code below without any success. Can someone please show me where I have gone wrong?
The custom post type is called ‘property’, and the category slug is ‘long-term’
<?php
$query= null;
$args=array(
'post_type' => 'property',
'tax_query' => array(
array(
'taxonomy' => 'category',
'field' => 'slug',
'terms' => 'long-term'
)
)
);
$query = new WP_Query($args);
if ( $query->have_posts() ) : $query->the_post(); ?>
<h2><?php the_title();?></h2>
<?php endif; ?>
<?php wp_reset_query(); ?>