Last active
March 11, 2016 13:57
-
-
Save CybMeta/7d82bf00772d47ce161e to your computer and use it in GitHub Desktop.
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
add_action( 'wp_head', 'cyb_add_search_box_schemas' ); | |
function cyb_add_search_box_schemas() { | |
if ( is_front_page() && (int) get_query_var( 'paged', 0 ) < 1 ) { | |
// Add schemas site markup for Site Name and Site Link search box. | |
// See https://developers.google.com/structured-data/slsb-overview | |
// and https://developers.google.com/structured-data/site-name | |
$searchbox = [ | |
'@context' => esc_js( 'http://schema.org' ), | |
'@type' => 'WebSite', | |
'name' => esc_js( get_bloginfo('name') ), | |
'url' => esc_js( home_url() ), | |
'potentialAction' => [ | |
'@type' => "SearchAction", | |
'target' => esc_js( home_url( '?s={search_term}' ) ), | |
'query-input' => "required name=search_term" | |
] | |
]; | |
?> | |
<script type="application/ld+json"> | |
<?php echo wp_json_encode( $searchbox ); ?> | |
</script> | |
<?php | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment