Using get_the_category
-
Greetings all,
I am trying to obtain the category ID(s) of a post currently being viewed (ie, in the single.php). The following code outputs the list of categories on screen (taken from the codex). How it be modified such that instead of echoing results to the screen, be saved as a variable (string). Any ideas?
foreach((get_the_category()) as $cat) {
echo $cat->category_id . ',';
}
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Using get_the_category’ is closed to new replies.