This tutorial includes the code which enables you to display related posts in the same category when that category is set as your primary category using the Primary Category setting in the category box on single post edit screens.
Note : Requires the installation of the Yoast SEO plugin to add the primary category option.
This primary category setting is used when you assign a post multiple categories and want to set a primary.
WPSEO_Primary_Term class in Yoast SEO.
Tested using the genesis Sample child them by StudioPress however will work in any Genesis child theme.
- # Copy and paste the PHP code ( without the opening PHP tag ) to the end of your child themes functions file.
- # Copy & paste the CSS from the style.css file to the end of your child themes style sheet and clear caching.
- # Install the Yoast SEO plugin and select the primary category for posts assigned multiple categories.