In the comments section of Custom Shortcode for Primary Category Link in Genesis Entry Meta using ACF tutorial, a user asked:
Hello Sridhar! This is helpful. Do you know how we could customize this to use the Yoast Primary Category instead?
Since version 3.1, Yoast SEO plugin supports designating a category as the primary category in post editor screen in WordPress.
In this tutorial, we shall create a custom
primary_post_category shortcode which returns the linked Yoast SEO primary category and use
genesis_post_meta filter hook to check if Yoast SEO is active and if so, whether a category has been set as the primary category and if so, call our custom shortcode instead of the default Genesis
This way, only if the Yoast SEO plugin is active and only if a category has been marked as primary will the post meta show it. Otherwise, the standard post meta.
Add the following in child theme's functions.php:
To view the full content, please sign up for the membership.
Already a member? Log in below or here.