Adding search to your theme
Place the following code in your theme
<form method="get" id="searchform" action="<?php bloginfo('home'); ?>/"> <input type="text" size="16" value="<?php echo wp_specialchars($s, 1); ?>" name="s" id="s" /> <input type="submit" id="searchsubmit" value="Search" class="btn" /> </form>
The search bar with the default text inside.
<form method="get" id="searchform" action="<?php bloginfo('home'); ?>/"> <input type="text" value="Search" name="s" id="s" onfocus="if (this.value == 'Search & Hit Enter') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Search & Hit Enter';}" /> </form>
Exclude pages from search results
Put the following snippet to your function.php file
function filter_search($query) { if ($query->is_search) { $query->set('post_type', 'page'); } return $query; } add_filter('pre_get_posts', 'filter_search');