Last active
July 22, 2018 00:30
-
-
Save Tabrisrp/ec82c78135733f05960f to your computer and use it in GitHub Desktop.
ADD microdata markup for Google sitelinks search box in WP search form
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
<div itemscope itemtype="http://schema.org/WebSite"> | |
<meta itemprop="url" content="<?php esc_url( echo home_url( '/' ) ); ?>"/> | |
<form itemprop="potentialAction" itemscope itemtype="http://schema.org/SearchAction" role="search" method="get" id="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>"> | |
<div> | |
<label class="visually-hidden" for="s"><?php _e( 'Search for:', 'themeslug' ); ?></label> | |
<meta itemprop="target" content="<?php esc_url( echo home_url( '/' ) ); ?>?s={s}"/> | |
<input itemprop="s" type="search" value="<?php the_search_query(); ?>" name="s" id="s" class="searchfield" placeholder="<?php _e( 'Input search terms', 'themeslug'); ?>" /> | |
<input type="submit" id="searchsubmit" class="searchsubmit" value="<?php _e( 'Search' ); ?>" /> | |
</div> | |
</form> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Lines 2 and 6 have one echo statement that should be pulled out of the esc_url(); I see you fixed this on line 3 in the last revision.