I suspect that I’ve been using the wrong terms looking for an answer. Pointers appreciated.
Using a this query:
<h3>client news</h3> <?php $my_query = new WP_Query('cat=4&showposts=3'); ?> <?php while ($my_query->have_posts()) : $my_query->the_post(); ?> <p><?php the_excerpt(); ?></p> <p class="readmore"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>">read more ></a></p> <?php endwhile; ?>
I’d like to have the <h3> show the category title instead of being typed in the template, so if the category is empty the title doesn’t show. But if the category title tag is added below the query, it shows above each post. Adding it between the query and the while tags shows “uncategorized”.
How can I get the category title to display only at the top of a list of posts?
- The topic ‘show category title once using my_query’ is closed to new replies.