WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a main page that consists of 7 categories being output by wp_list_categories, each li specifically includes one ID. These categories are directed to a category-page.php specifically built for each category. Now, each category has sub categories. So on each of the category pages, I want to build out custom queries for each sub category. Example: the Weightloss category on the main page, links to the category-weightloss.php page. Within Weightloss, there are six sub categories. What is the best way, to create six different queries, in seperate div's, so I can style them? I have looked over WP_Query, but I am not sure of the best, and most appropriate, way to do this.

share|improve this question
up vote 0 down vote accepted

I figured this out on my own. I use the code below and duplicated it as many times as I needed without any issues so far. If anyone thinks this is incorrect than please comment. I was not using the main loop anywhere else on this page and used WP_Query.

<ul class="subcats-list">
$weightloss = new WP_Query();

while ($weightloss->have_posts()) : $weightloss->the_post(); ?>
    <li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li>
<?php endwhile; ?>

 </ul><!-- subcat -->
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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