Created
April 3, 2017 04:13
-
-
Save awakekat/942819e3a21870c563ee4c9c4913a7aa to your computer and use it in GitHub Desktop.
Wordpress Custom 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
custom-search-form.php | |
============================================ | |
<div class="content-search"> | |
<form role="search" method="get" id="searchform" class="searchform" action="<?php echo get_site_url(); ?>"> | |
<div> | |
<label class="screen-reader-text" for="s">Search for:</label> | |
<input type="text" value="<?php the_search_query(); ?>" name="s" id="s" /> | |
<?php wp_dropdown_categories( array( | |
'show_option_all' => 'All Posts', | |
'orderby' => 'name', | |
'echo' => 1, | |
'selected' => $cat, | |
'hierarchical' => true, | |
'class' => 'cat-dropdown', | |
'id' => 'custom-cat-drop', | |
'value_field' => 'term_id' | |
) ); ?> | |
<input type="submit" id="searchsubmit" value="Search" /> | |
</div> | |
</form> | |
</div> | |
============================================ | |
HTML/PHP | |
============================================ | |
<?php get_template_part('custom-search-form'); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment