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

On my CMS-style setup, I have the standard search box which searches everything.

However, on my blog page, I would like to also have another search box which searches just the blog... is this possible, and how would I go about it?


I used this code within a text widget which goes on my blog page:

<form  id='searchform' method='get'>
<input style='margin-top:5px;' type='text' name='s' id='s' placeholder='Search (blog only)'>
<input type='hidden' name='post_type' value='post' />

This has the advantage that the results page is styled like the blog, and not the standard search page. (though I don't know how to indicate that the page is showing search results.. how to show this?)

share|improve this question
I would like to STRONGLY encourage you to accept answers to some of your other questions. You currently have a 14% accept rate, which (in my opinion) significantly decreases the amount of effort other members of the site will be willing to put into answering your question. – tnorthcutt Sep 10 '10 at 15:37
Would it work for the blog search box to be limited to searching posts only? – tnorthcutt Sep 10 '10 at 15:39
@cannyboy: Regarding accepting answers, what @tnorthcutt said... – MikeSchinkel Sep 11 '10 at 9:32
thanks for the tip! – cannyboy Sep 11 '10 at 15:46
Hi @cannyboy: No problem, thanks for hanging out here and asking good questions! – MikeSchinkel Sep 11 '10 at 23:02
up vote 1 down vote accepted

Hi @cannyboy:

There's a plugin called Search Unleashed that gives lots of different functionality. One of my clients was using it and I was impressed with the control it gave. Not 100% sure it will give you what you need but it's worth checking out.

If your blog only has post_types of "post" and you don't use them for the rest of the site you could use @TerryMatula's suggestion but with $post_type => 'post' instead, i.e.:

<input type="hidden" name="post_type" value="post" />

share|improve this answer
Thanks, I ended up putting this code in the text widget on my blog page (see my updated question) – cannyboy Sep 11 '10 at 15:50

If the Blog is in its own category, you could copy the searchform.php code, and then add this:

<input type="hidden" name="cat" value="{your category id}" />

of course, replacing {your category id} with the actual ID number. You could either put the entire form code into a widget, or directly into your template.

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.