I am using the following code to display a list of posts within a category, but I want to display the title in it's own h2 tag above the list.
<ul class="subcats-list">
<?php
$weightloss = new WP_Query();
$weightloss->query('showposts=5&include=4');
while ($weightloss->have_posts()) : $weightloss->the_post(); ?>
<li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li>
<?php endwhile; ?>
</ul><!-- subcat -->
EDIT:
So I tried using single_cat_title
, however, the title is coming up for the parent category for all the sub category divs. Here's an example of a div that I am replicating multiple times, where the query is pulling posts from different sub categories. I would like the title for each sub category above the posts. I realize it's not working because I'm returning the parent category with that function, I'm just can't figure out the php...
<ul class="subcats-list">
<h2 class="subcats-title"><?php single_cat_title(); ?></h2>
<?php
$weightloss = new WP_Query();
$weightloss->query('showposts=5&cat=4');
while ($weightloss->have_posts()) : $weightloss->the_post(); ?>
<li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li>
<?php endwhile; ?>
</ul><!-- subcat -->
include
? Is that a valid argument?cat=4
, not include. I am using this snippet multiple times on one page. So I wanted to display the category above the list.