How can I “fetch” custom category name or id on archive.php page. So when i’m on that page template, how can i know which custom category posts are showing?
Leave a Reply
You must be logged in to post a comment.
How can I “fetch” custom category name or id on archive.php page. So when i’m on that page template, how can i know which custom category posts are showing?
You must be logged in to post a comment.
Use
get_queried_object();
to retrieve the currently-queried object.In a taxonomy term case:
Displays the following:
Hope it helps!
Check if this code helps ??
If you are trying to display the current category on your archive.php page, for instance, if your url is:
Then to echo ‘design’ you would use the following:
On my archive page I have the following:
That displays the category ‘design’ in an h1 tag. I hope this helps someone.
The simple is the best
Try the this piece of code to get the category name!!
$cat_name = single_cat_title(”,false);