Skip to content

Instantly share code, notes, and snippets.

@srikat
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save srikat/63c121b7938406aec50a to your computer and use it in GitHub Desktop.
Save srikat/63c121b7938406aec50a to your computer and use it in GitHub Desktop.
How to display Search box within content in WordPress. http://sridharkatakam.com/display-search-box-within-content-wordpress/
<?php
//* Do NOT include the opening php tag
//* Create a [my_search] shortcode for displaying search box
add_shortcode('my_search', 'display_search');
function display_search($atts) {
ob_start();
echo '<div class="my-search">';
get_search_form();
echo '</div>';
return ob_get_clean();
}
.my-search {
margin-bottom: 28px;
}
.my-search input[type="search"] {
max-width: 300px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment