Skip to content

Instantly share code, notes, and snippets.

@ziodave
Last active October 24, 2018 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ziodave/caf95471040fb8765c099071d8122550 to your computer and use it in GitHub Desktop.
Save ziodave/caf95471040fb8765c099071d8122550 to your computer and use it in GitHub Desktop.
Add WebSite mark-up on category pages
<?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