Ready to get started?Download WordPress


Different search forms which search different categories? (4 posts)

  1. thesheep
    Posted 5 years ago #

    I'm working on a site which uses a single installation of WP as a CMS for the main site, as well as for a blog on the same domain.

    The main site uses both pages and posts (posts are used for things like papers and news items). The blog uses posts for blog posts. The different types of posts are of course defined as different categories.

    The client wants to have 2 different search forms on the site, which have different scopes. The first will search the entire site. But a second will be used to search only a sub-set of categories - i.e. this search box will be used to search blog posts only.

    In addition the 2 different search forms need to return search results that are styled differently (as well as searching in different categories).

    Does anyone know if this is possible and how I might go about implementing it?

  2. thesheep
    Posted 5 years ago #

    My initial thinking is to put some clever logic in the template search.php that tests for a hidden variable set in the search form. If it finds variable A then it displays only certain categories. If it finds variable B then it displays other categories.

    Will the hidden variables carry through OK? I guess I'll give it a try.

  3. thesheep
    Posted 5 years ago #

    That actually works OK. In case anyone else needs it in future, I just wrote a quick blog post to explain what I did:

  4. thesheep
    Posted 5 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic