views:

32

answers:

1

Say I have a wordpress search box that searches the site for whatever is typed into the text field. Like so:

    <form action="<?php bloginfo('siteurl'); ?>" method="get">
<input name="s" type="text" value="Search here..." />
<input id="sermon_search_submit" type="submit" value="GO!" />
 </form>

This searches the entire site fine, but how would I make it only search on a certain page. For example I want to search all the posts on a certain page. How would I specify that?

+1  A: 

You can make this happen by appending &s=search+term at the end of any wordpress URI.

for example, to search in june only:

http://tomdignan.com/wordpress/?m=201006&amp;s=php

Try it yourself!

You could probably fix this in your search box by instead of having it say bloginfo('siteurl') in the form action attribute, it says bloginfo('siteurl') + current page.... or something along those lines. If you look on codex.wordpress.org i am sure you'll find a library function that can do something like that for you.

Hope this helps.

Tom Dignan
Thanks! This looks pretty simple. I'll see if it works.
codedude