I would like to get all the posts under a category (custom post type ui category) into a different template other than archive.php or category.php.

I tried normal way of getting the posts using category id, but it returns empty array. Please help.

  • why don't you share your code that you already tried ?
    – mlimon
    Commented Oct 27, 2016 at 22:41

2 Answers 2


Worked perfectly for me!! Code will bring the posts(under CPT UI) to any page template.

$loop = new WP_Query( array( 
    'post_type' => 'specialoffers', 
    'cat' => '12', // Whatever the category ID is for your aerial category
    'posts_per_page' =>  10,
    'orderby' => 'date', // Purely optional - just for some ordering
    'order' => 'DESC' // Ditto
) );

while ( $loop->have_posts() ) : $loop->the_post(); ?>

custom post type ui category

It sounds like you might be referring to a custom taxonomy that you created with the "Custom Post Type UI" plugin. If that's the case, then you'll need to use a taxonomy template: taxonomy.php.

Wordpress Template Hierarchy

category.php and tag.php are only used for the built-in "category" and "tag" taxonomies.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.