I noticed that on articles with multiple categories, the category selected as the PRIMARY is not what is reflected within breadcrumbs. Instead, it displays only the category that would come first Alphabetically. How can I force breadcrumbs to use Primary Category in the breadcrumb when there are multiple categories in play?
Hello Jesse,
Thanks for the very detailed post information. Please be advised that in WordPress, there is no primary and secondary category. What we have are the parent and child categories. Be also aware that a post can have as many categories as you can assign. And this is why the breadcrumbs will only display the very first category in alphabetical order. There is no way to force WordPress to display a specific category in the breadcrumb because treats every category assigned to a post equally.
Hope this makes sense.
Primary category exists as an option on the backend.
What purpose does it serve if not to denote breadcrumb priority?
Hello Jesse,
Are you using Yoast SEO plugin? On my local testing server, I only have this:
The default breadcrumb element will only display “Home -> Blog -> Post Name”. It seems that you added a custom PHP code in your child theme that will display the category. You will need to modify your code and use the right PHP function to display the WordPress primary category. Be advised that custom coding is beyond the scope of our support. You may need to contact a 3rd party developer or someone who has created your custom code and do the customization for you. Meanwhile, you can use the following link as a guide:
- https://travis.media/get-the-primary-category-of-a-post/
- https://stackoverflow.com/questions/43114986/get-primary-category-if-more-than-one-is-selected
- https://wordpress.stackexchange.com/questions/228821/how-to-get-primary-category-name-in-wordpress-new-version
Thank you for your understanding.
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.