This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get the Yoast primary category from its post meta value, and displays it, with HTML markup. | |
* If there is no primary category set, it displays the first assigned category. | |
* | |
* @param boolean $useCatLink Whether to link the category, if it exists | |
* @return void | |
*/ | |
function yourtheme_display_yoast_primary_category( $useCatLink = true ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Creating Shortcode to display Yoast SEO Primary Category | |
// Add Shortcode | |
function get_yoast_primary_cat() { | |
$category = get_the_category(); | |
$useCatLink = true; | |
// If post has a category assigned. | |
if ($category){ | |
$category_display = ''; |