Need Help Getting the Category for Current Archive
-
Hello, folks.
My issue is as follow:
https://www.tvovermind.com/category/tv-news
You see that the template reports “Archive for the ‘TV News’ Category”
And the code doing that is:
<h4 class="pagetitle">Archive for the ‘<?php single_cat_title(); ?>’ Category</h4>
However, I cannot get the information from single_cat_title(); into a variable. single_cat_title(); as you know echos the result. I tried:
$category = get_the_category();
echo $category[0]->cat_name;But it gave me the category for the first post listed in the archive, instead of the category for the archive itself.
I need to be able to get the name of the category that the archive is displaying into a variable. Any ideas?
- The topic ‘Need Help Getting the Category for Current Archive’ is closed to new replies.