WordPress.org

Ready to get started?Download WordPress

Forums

Multiple category searches via one query link? (17 posts)

  1. marc0047
    Member
    Posted 9 years ago #

    Is there a way to pull up multiple category searches through one query link? For example, let's say I have the following three categories:

    Apple
    Banana
    Kiwi

    Most of the time, my articles will only have one association with a category. But there will be times where they will have more than one. In the event that an article, for example, has a category association with Apple *and* Banana, is there a URL query string that pulls up searches for both?

    like ?search=apple+banana

    Thanks,
    Marc

  2. gpaulson
    Member
    Posted 9 years ago #

    I would be interested in being able to do the same - like being able to check the boxes of the categories you want to 'and' together.

  3. Lorelle
    Member
    Posted 9 years ago #

    I believe all you have to do is include both words and search like you would on Google or Yahoo or wherever.

    search: apple banana

    or I think you might be able to use quotes and pluses like this:

    search: +apple +banana

    search: "apple banana"

    Give it a try.

    The searches go across categories already.

  4. Kafkaesqui

    Posted 9 years ago #

    Think space:

    ?s=search%20text&cat=9%2010

    That's a search of category IDs 9 and 10 (%20 is a space in hex/URL encoding). I don't know if there's a way of affecting this through the category slug/name (and I've tried).

  5. likoma
    Member
    Posted 9 years ago #

    I agree that the advanced search techniques are possible for the users who know how to use them, but I need a search box and then checkboxes for the different categories. To use marc0047's example in my site, I'd want to make two sets of boxes, one for location (Los Angeles, San Francisco, etc.) and the other for job description (Painter, Plumber, etc.). I'd want to be able to check boxes:

    JOB SEARCH

    Location:
    [x] Los Angeles
    [] San Francisco

    Job:
    []Painter
    [x]Plumber

    So that with Los Angeles and Plumber checked, the search results would show me all jobs in L.A. for Plumbers (and not ALL jobs in L.A. or ALL Plumber jobs).

    Is this beyond WordPress? If so, any suggestions on something I could use to make this work? The site in question is currently in an old MT install that I'd love to move to WP, but I do need this advanced search to work.

    If someone can guide me to simple hack/plugin, I'd be much obliged. If it looks like it's a more-than-simple hack/plugin, I'm ready to talk dollars.

    Thanks for any leads, links, letters, or laughs.

    - Bradley

  6. likoma
    Member
    Posted 9 years ago #

    I just posted an ad on Craigslist (http://www.craigslist.org/sfc/cpg/75913683.html) for some help, but I'd rather have some help from within the WordPress family if anyone out there can help me.

    I'd also rather move my site to WordPress from MovableType and THEN solve this problem unless it's an easy solution within MovableType. Or maybe integrating some PHP database-type thing? Or switch completely to some other software? I don't know what those others can do (e.g. Drupal, TextPattern, etc.).

    Thanks again.

    - Bradley

  7. sujaikumar
    Member
    Posted 9 years ago #

    Wondering if Bradley/likoma's request is possible, or if someone knows enough PHP to hack together an "AND" search like what he is talking about.

    I looked inside classes.php (WP 1.5.1.2/wp-includes) and found on line 388:
    $andor = 'OR';
    I tried changing this to 'AND' to see if that would get me an "AND" search rather than an "OR" search but now it doesn't find anything. I think I see why this doesn't work, but am at a loss for how to get it to search for posts that belong to category x AND category Y.

    Any help would be greatly appreciated (of course). Thanks in advance.

    - Sujai

  8. sujaikumar
    Member
    Posted 9 years ago #

    One of the helpful folks on IRC suggested I try http://dev.wp-plugins.org/wiki/Tags

    "http://your.blog.site/index.php?tags=tag1+tag2+tag3
    The URL means you access posts which have tag1 and tag2 and tag3. "
    Sounds like just what I need. Only catch is that the tags assigned to each post are totally different from the categories, so none of the wonderful category plugins will probably work...

  9. sujaikumar
    Member
    Posted 9 years ago #

    The aforementioned tags plugin is by Felix Wong (http://boke.name/c/wordpress-tags). Thanks Felix.

    The plugin works as described. So this will do for now. But it would still be great to have this functionality for Categories as well. Any takers?

    Some things to keep in mind:

    1. It involves changing three files in /wp-admin (for an input field to enter tags)

    2. The tags can only be space separated. I made the mistake of typing "mumbai, health" and got errors when I tried to access the URL "http://blog.site/tags/mumbai" because the "," got stored as part of the tag

    3. You have to uninstall the "Post tags" plugin first because there is a conflict (both use 'tags' as part of the URL to access tagged info)

  10. MK Safi
    Member
    Posted 8 years ago #

    it's been 8 months since this was last discussed.

    i installed UltimateTagWarrior, but i wish to allow my visitors to query posts based on multiple tags. is this possible in a user-friendly way?

    thanks,

  11. fumbly
    Member
    Posted 8 years ago #

    I've also come across this issue and would like to be able to pull up search results that only appear in multiple categories. I'm not particularly keen on using a tag plugin because it's the categories I'm after. Anyone got anymore suggestions?

  12. fooddude
    Member
    Posted 8 years ago #

    Add me to the list of users wanting this function. I don't care if it is based on tags because I can convert catergories to tags with Ultimate Tag Warrior. It seems amazing to me that no none has been able to do this. I think it would be very popular.

  13. dealhunter
    Member
    Posted 8 years ago #

    Add me as well to this list.

  14. fooddude
    Member
    Posted 8 years ago #

    The newest version of Ulimate Tag Warrior 3.0 does this quite well if you are willing to play around with it. I've implemented it as a search on my site if you want to check it out: http://www.portlandfoodanddrink.com/?page_id=356 Note that I'm still tweaking the page.

    UTW can be found at http://www.neato.co.nz/ultimate-tag-warrior

  15. likoma
    Member
    Posted 8 years ago #

    Fooddude,

    Not only does it work, but it's fun! Thanks for posting here.

    I'm going to need this to work (in some format) very soon as I'm redoing the job search site in WP (was MT). Just found a competitor of theirs that has a very nice search function doing just what I need (not as fun as Fooddude, though!):

    MHA Global (search)

    I'll go checkout UTW 3.0, thanks.

  16. Ryan Fitzer
    Member
    Posted 8 years ago #

    Fooddude,

    That's great! How did you configure the "and" and "or" search feature?

  17. likoma
    Member
    Posted 8 years ago #

    Ryanfitzer,

    I found it, it's a template from UTW. Works like a dream!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags