I’m new to wordpress and have a quick question about showing a post’s category names. I have two main categories
Games
- free cell
- solitaire
-
classic games
— pong
— ms. pacman
Featured Games
etcetera. So that I can make a post and tag what game it is from (note that there are three tiers here). If my post was a screen grab of ms. pacman, i would choose the Games > Classic Games > Ms. Pacman category. I might also want this awesome image in my home page featured slider, so I might choose Featured Games as well.
However!!! When I get to the post detail page, i just want to spit out CATEGORY: Ms. Pacman. I don’t want Games / Classic Games or Featured Games.
So now, I have
<?php the_category(', ', 'single');?>
To show only the child element, but it is still showing all three levels as well as the Featured categories. I think I need to exclude that “featured category” id from the query but don’t know how. Here’s my specific code:
<?php if ( have_posts() ):?>
<?php while ( have_posts() ) : the_post();?>
<div class="category">CATEGORY: <?php the_category(', ', 'single');?></div>
<?php endwhile;?>
<?php endif;?>
I don’t know how to do custom queries or what to change or where to change it. Is this possible?
It seems there aren’t any filters that will easily produce what you’re looking for, but it should be possible to put something together using the source code of get_the_category_list which you can find here: http://core.trac.wordpress.org/browser/tags/3.3.2/wp-includes/category-template.php#L0
Like this, change the markup as you please: