Display only primary Category in Theme (Frontend)
-
Hi,
our client had this never in mind, but as he saw that he can select a primary category, he starts using more than one cat for each article.
On the front page I have this code usually to display the category name:
<?php foreach((get_the_category()) as $category){ echo $category->name; } ?>
I know that WordPress does or at least did the category order from the lowest ID to the highest.
Now, of course, I get multiple category names displayed in the frontend, as my client does choose them in the backend.
So, how can I achieve this, that the (a) category name gets displayed, but if there is a primary from yoast selection, this should be displayed instead?
Thanks for your Help in advance!
Best regards
Mikkel
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Display only primary Category in Theme (Frontend)’ is closed to new replies.