- This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
Viewing 3 posts - 1 through 3 (of 3 total)
- The forum ‘Back End’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Is there a way to call a single child name of a category?
This is what I mean. I have posts that have multiple categories based on hierarchy.
Magazine
-> Department
->-> Humor Me
->-> Letters to the Editor
->-> LifeStyle
-> Issue #35
None of the posts multiple categories of the last set. Just one. For example, The post titled “The Story of My Life” is in the categories: Magazine, Department, Issue #35 and Humor Me.
Each post must have an Issue category and one from the last level category ie. “Humor Me”
In my template I want to display something like this-> Humor Me: The Story of My Life
I can get them to all display “Department: The Story of My Life” or all of the associated categories but not just the last on the list.
Thanks
This is what I ended up using. It seems to be working.
$catpost = get_the_category();
foreach ($catpost as $cat) {
if($cat->category_parent==21){
$namecat= $cat->cat_name;
echo $namecat;
}
}
?>
I know its late, But you can use
<?php the_category(“”, “single”); ?>; // inside loop
<?php the_category(“”, “single”, $post->ID); ?> // outside loop
You can see the reference here . We are using it in our site.