Last active
October 24, 2018 09:40
-
-
Save ziodave/caf95471040fb8765c099071d8122550 to your computer and use it in GitHub Desktop.
Add WebSite mark-up on category pages
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 | |
add_filter( 'wp_head', function() { | |
// Bail out if it's not a category. | |
if ( ! is_category() ) { | |
return; | |
} | |
// Check that the Wordlift_Jsonld_Service exists. | |
if ( ! class_exists( 'Wordlift_Jsonld_Service' ) ) { | |
echo '<!-- WordLift JSON-LD service not found. -->'; | |
return; | |
} | |
// Get the JSON-LD, $is_homepage = `true`. | |
$jsonld = json_encode( Wordlift_Jsonld_Service::get_instance()->get_jsonld( true ) ); | |
// Finally print the JSON-LD out. | |
?> | |
<script type="application/ld+json"><?php echo $jsonld; ?></script> | |
<?php | |
}, 10, 0 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment