WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
<form role="search" method="get" class="search-form-for-post form-inline" action="<?php echo home_url('/'); ?>">
    <div class="input-group">
        <input type="search" value="<?php if (is_search()) { echo get_search_query(); } ?>" name="s" class="search-field form-control" placeholder="Enter Keyword">
        <label class="hide"><?php _e('Search for:', 'roots'); ?></label>
        <span class="input-group-btn">
            <button type="submit" class="search-submit btn btn-default"><?php _e('SEARCH', 'roots'); ?></button>

I have written above code in content-single.php It is searching pages also.I want to search only post when I am Searching from post

share|improve this question
Try adding <input type="hidden" name="post_type" value="post" /> somewhere inside the <form /> – TheDeadMedic Jun 1 '14 at 14:00
I have tried that but it still displaying pages – bhagyashree Jun 1 '14 at 14:18
What processes your form? – s_ha_dum Jun 1 '14 at 14:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.