WordPress.org

Ready to get started?Download WordPress

Forums

Multiple Category Drop Down Boxes to Search Posts (13 posts)

  1. ImagineDesignEx
    Member
    Posted 4 years ago #

    I'm working on a project that has a listing of workshops. Categories in this case might include things like the artist giving the workshop, the location, the year, the topic, and etc.

    What I'm trying to do is put together a series of drop down boxes that will allow you to filter the posts: Artist #1 is giving a workshop in 2010 in Arizona, for example.

    I've found the multiple-category-selection-widget which is PERFECT for this, but it seems to be broken in WordPress 2.8.4.

    I've tried doing custom search forms that have the drop down boxes, but when the search query comes up, we have a format like this: /?s=&cat=13,17 - This query brings up all posts in categories 13 and 17, not just the posts that are in BOTH 13 and 17.

    Does anyone have a method or any advice on what to do about this problem? I need something that will let me do the search based on posts that are ONLY IN the selected categories, not ALL the posts that are in ALL the selected categories.

    I've seen a lot of other people trying to do this, but I haven't really seen a solution other than the multiple-category-selection-widget (again, its broken). Some of the other advanced category or search plugins say they'll do something like this, but I've not found anything that's quite right.

    Thanks!

  2. mediabros
    Member
    Posted 4 years ago #

    i would love to see this issue solved!

  3. petezarustica
    Member
    Posted 4 years ago #

    Me too.

  4. soulgeek
    Member
    Posted 4 years ago #

    Shame no solution Still!!!!

    Am sure there are solutions for this, will anyone help us out?

  5. Shane G.
    Member
    Posted 4 years ago #

    Hi,

    Refer this article:

    http://codex.wordpress.org/Template_Tags/wp_dropdown_categories

    Thanks,

    Shane G.

  6. bn07.bn07
    Member
    Posted 4 years ago #

    I too have the same problem. Pls help if u got the solution.

  7. noelgreen
    Member
    Posted 4 years ago #

    Yep... I just posted about this.
    http://wordpress.org/support/topic/380644

    Any luck?

  8. takien
    Member
    Posted 4 years ago #

    my idea is like this:
    get category id from $_GET method.. yoursite.com/?s=some+term&cat=2,
    it's assumed will only search "some term" only in category 2...

    please customize your own search form using wp_dropdown_categories().. it's pretty simple i think...

    then you have to make a function something like my_search_filter();

    function my_search_filter() {
    $thecat = $_GET['cat'];
    $where = "AND post_category = $thecat";
    return $where;
    }
    
    if(is_search()) {
    add_filter('posts_where','my_search_filter');
    }

    place that code in your functions.php inside current theme directory...

  9. noelgreen
    Member
    Posted 4 years ago #

    Thanks man!

    I updated my function.php, but what does the actual search button look like... or the drop downs menus?

    Here's my search box / button...

    <form method="get" id="searchform" action="<?php bloginfo('url'); ?>/">
    <input type="text" value="<?php echo wp_specialchars($s, 1); ?>" name="s" id="s"/>
    <input type="hidden" name="cat" value="16" />
    <input type="submit" id="searchsubmit" value="Search" /><br />

    And here's one of my drop downs...

    php wp_dropdown_categories('depth=0&child_of=22&orderby=name&hide_empty=0&show_option_all=Any');

    Can you post a full working multiple drop down example?????

  10. noelgreen
    Member
    Posted 4 years ago #

    Here's an example of a site that does pretty much exactly what I want... though I don't think they're really using a "search" feature...

    http://gorillathemes.com/broker/?wptheme=Broker-Real-Estate-White-Style

  11. takien
    Member
    Posted 4 years ago #

    Hi.. i just write a simple plugins to do that..
    You don't need to edit any files. Just install and go..

    http://takien.com/678/wordpress-search-filter-plugins.php

    gorillathemes.com is using custom field... not just the category.
    http://codex.wordpress.org/Custom_Fields

  12. castmir
    Member
    Posted 3 years ago #

    gorillathemes.com is using Categories!!, no custom field.

  13. vtxyzzy
    Member
    Posted 3 years ago #

    I just downloaded and installed Multiple Category Selection Widget in my 2.8.6 test bed, and it works.

    You need to be sure that you have Parent/Child categories set up or it doesn't select anything. I tried it with this structure:

    Cities
    - Dayton
    - Columbus
    - Monroe

    Lodging
    - Hotels
    - Motels

    Attractions
    - Museums
    - Parks

Topic Closed

This topic has been closed to new replies.

About this Topic