Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.
<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>
        </span>
    </div>
</form>

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 at 14:00
    
I have tried that but it still displaying pages –  bhagyashree Jun 1 at 14:18
    
What processes your form? –  s_ha_dum Jun 1 at 14:58

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.