Getting hold of the category when using single.php
-
Hello
On my site (http://www.luxurywatches.name) I have a need to extract the category that the post belongs to, when I am using the single.php file – this would be when I am viewing a specific post under a specific category, meaning that the single.php file is in use.
When I need the category, I normally use the single_cat_title() function to grab a hold of the category.
In this case, I need to use the single_cat_title() function in the header.php file. The file single.php will then include the header.php file.
When I try to view a single post, single_cat_title() in the header.php returns nothing, so it is not set thereOn the other hand, if I try to get a hold of the category in the header.php that is included by the category.php, then it works all right.
So the bottom line is the followig:
I use the single_cat_title() to extract the category in the header.php file. If it’s the category.php file that includes the header.php file, then everything is OK and I will get the category. But if the header.php file is included by the single.php file, then I cannot get a hold of the category of the post.Can someone please help me ?
- The topic ‘Getting hold of the category when using single.php’ is closed to new replies.