I’m trying to alter what my
single.phptemplate outputs depending on the category of the post. I add this code in the loop:
<?php $allcats = get_the_category(); $postcat = $allcats->cat_name; ?>
$postcatto return the name of the current post’s category (posts only have one category). My site has a total of 5 categories.
I’m finding that the value of $postcat is always ‘report’, regardless of whether this is the category of the post. ‘report’ was the last category I added to the site.
Am I misunderstanding or misusing
- The topic ‘Probs with get_the_category – always returns same category’ is closed to new replies.