• We are available for any Development work:
  • Email us at: programmer_heart@yahoo.com

Get all post of certain category of particular post type in wordpress

You can use following code to display all post related to certain category of any custom post type.


global $post;

$params_mostwatched=array(
'post_type' => $post_type,
'post_status' => 'publish',
'tax_query' => array(
array(
'taxonomy'  => $post_type.'_category',
'field'     => 'term_id',
'terms'     => $cateid
))
);
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query($params_mostwatched);
while ($wp_query->have_posts()) : $wp_query->the_post();

echo $post->post_title;

endwhile;

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Current day month ye@r *

Press Enter to Search