• I recently upgraded to the current version of WP. Instead of using one of the default themes, I ported my existing site into a custom theme.

    I would like to add search functionality to my site, but frankly, don’t have a clue where to begin. Can somebody point me to a simple tutorial, or give me some idea of how to start?

Viewing 13 replies - 1 through 13 (of 13 total)
  • The best bet is to look at the two themes (Classic and Default) that come with the standard WP package… and “steal” from there how did they do it 🙂

    Thread Starter jgurley

    (@jgurley)

    Actually, I did that. I just get lost when I’m looking at PHP that I don’t understand (I’m far from comfortable with PHP, to be honest).

    Default has a separate file called searchform.php and it is called with 1 (one) line of code.
    Classic has it in the sidebar and probably it starts with something like: <form...

    No PHP involved, it’s basic html
    http://www.w3schools.com/html/html_forms.asp

    Thread Starter jgurley

    (@jgurley)

    I’ll give it a fresh look, thank for the help.

    Thread Starter jgurley

    (@jgurley)

    Moshu, I’ve stripped the <form> out of the Default template and plugged it into my site (www.deeplyshallow.com, see the left sidebar, beneath all sidebar content) to test it.

    The form works, but it doesn’t return actual results… instead, it returns the most recent entry that contains that term.

    How do I modify it to return actual results instead of a full entry?

    I assume you have set your blog to show 1 post on main page AND you don’t have the post_nav_link to navigate to earlier posts.

    You may want to consider creating a search.php template file >> see Template_Hierarchy

    EDIT. And of course, you’llhave to find a way to change the number of posts displayed on that page, e.g. with one of these plugins:
    http://mattread.com/archives/2005/03/custom-query-string-plugin/
    http://rephrase.net/miscellany/05/perpage.phps

    Thread Starter jgurley

    (@jgurley)

    Blog’s set to show 1 post on the page, yes. And I use the previous_post/next_post links to get to earlier/newer posts.

    Is it possible to just display a results page with a list of links to posts, instead of the actual posts? Making someone search and then presenting them with an inordinately long page of multiple posts, with no easy way of choosing which one is what they’re looking for, seems like more trouble than it’s worth. (For the reader, I mean.)

    Is it possible to just display a results page…
    That’s exactly what showed above. In that template it is up to you whether you display the whole post, the excerpt or only the title.

    Thread Starter jgurley

    (@jgurley)

    Okay, sweet! One last thing: is there a guide anywhere for creating a search.php template? Anything to help me with the process?

    Thanks very much for your help/patience.

    Save your index.php (or better the archive.php – if you have one) as search.php and play with the template tags: Template_Tags.
    In general about template files in a WP theme, see Templates

    Thread Starter jgurley

    (@jgurley)

    I have an archive.php, but it uses Shawn Grimes’s Clean Archives plug-in — in that case would it be better to use the index.php as the basis instead?

    Nope, that’s not a template file as I see it. Use the index.

    Thread Starter jgurley

    (@jgurley)

    Great. Thanks!

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Help with search’ is closed to new replies.