Last active
August 29, 2015 14:06
-
-
Save Tabrisrp/f99dd022672e2b558e0e to your computer and use it in GitHub Desktop.
Add JSON+LD markup for Google sitelinks search box
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_action( 'wp_footer', 'rp_add_google_search_markup' ); | |
function rp_add_google_search_markup() { | |
if ( is_front_page() ) { | |
?> | |
<script type="application/ld+json"> | |
{ | |
"@context": "http://schema.org", | |
"@type": "WebSite", | |
"url": "<?php echo esc_url( home_url( '/' ) ); ?>", | |
"potentialAction": { | |
"@type": "SearchAction", | |
"target": "<?php echo esc_url( home_url( '/' ) ); ?>?s={s}", | |
"query-input": "name=s" | |
} | |
} | |
</script> | |
<?php | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment