Title: Multi-Category Search
Last modified: August 20, 2016

---

# Multi-Category Search

 *  Resolved [adhanaraj](https://wordpress.org/support/users/adhanaraj/)
 * (@adhanaraj)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/multi-category-search/)
 * Hey there guys!
 * Just trying to figure this out – is there a way to have more that one category
   box to search from? A lot of my events have two or three categories they fall
   under and I would love to be able to filter them. I tried just duplicating the
   category box a few times and then filtering a la
 *     ```
       <?php
       				$selected = !empty($_REQUEST['category']) ? $_REQUEST['category'] : 0;
       				EM_Object::ms_global_switch(); //in case in global tables mode of MultiSite, grabs main site categories, if not using MS Global, nothing happens
       				wp_dropdown_categories(array( 'hide_empty' => 0, 'orderby' =>'name', 'exclude_tree' => '1407, 1412, 35', 'name' => 'category', 'hierarchical' => true, 'taxonomy' => EM_TAXONOMY_CATEGORY, 'show_option_none' => get_option('dbem_search_form_categories_label'), 'class'=>'em-events-search-category boxit'));
       				EM_Object::ms_global_switch_back(); //if switched above, switch back
       			?>
       			<?php
       				$selected = !empty($_REQUEST['category']) ? $_REQUEST['category'] : 0;
       				EM_Object::ms_global_switch(); //in case in global tables mode of MultiSite, grabs main site categories, if not using MS Global, nothing happens
       				wp_dropdown_categories(array( 'hide_empty' => 0, 'orderby' =>'name', 'exclude_tree' => '1403, 1412, 35', 'name' => 'category', 'hierarchical' => true, 'taxonomy' => EM_TAXONOMY_CATEGORY, 'show_option_none' => get_option('dbem_search_form_categories_label'), 'class'=>'em-events-search-category boxit'));
       				EM_Object::ms_global_switch_back(); //if switched above, switch back
       			?>
       			<?php
       				$selected = !empty($_REQUEST['category']) ? $_REQUEST['category'] : 0;
       				EM_Object::ms_global_switch(); //in case in global tables mode of MultiSite, grabs main site categories, if not using MS Global, nothing happens
       				wp_dropdown_categories(array( 'hide_empty' => 0, 'orderby' =>'name', 'exclude_tree' => '1403, 1407, 35', 'name' => 'category', 'hierarchical' => true, 'taxonomy' => EM_TAXONOMY_CATEGORY, 'show_option_none' => get_option('dbem_search_form_categories_label'), 'class'=>'em-events-search-category boxit'));
       				EM_Object::ms_global_switch_back(); //if switched above, switch back
       			?>
       ```
   
 * but then the search breaks. Help would be great! Thanks.
 * [http://wordpress.org/extend/plugins/events-manager/](http://wordpress.org/extend/plugins/events-manager/)

Viewing 9 replies - 1 through 9 (of 9 total)

 *  Thread Starter [adhanaraj](https://wordpress.org/support/users/adhanaraj/)
 * (@adhanaraj)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/multi-category-search/#post-3490029)
 * I guess I should be more specific with the search breaking part – it only accepts
   the value from the last one (as would be expected, I guess)
 *  [agelonwl](https://wordpress.org/support/users/angelonwl/)
 * (@angelonwl)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/multi-category-search/#post-3490124)
 * hi,
 * sorry for the confusion, is this using the events search form? I think this snippet
   is a good start – [http://pastebin.com/V96b5RN9](http://pastebin.com/V96b5RN9)
 * e.g.
    you can put your categories in an array and then used it in the category
   search attribute
 *  Thread Starter [adhanaraj](https://wordpress.org/support/users/adhanaraj/)
 * (@adhanaraj)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/multi-category-search/#post-3490138)
 * Yep, its to do with the events search form. Thanks for the start, taking a crack
   at it now :). Just stuck it in and playing around with it, will come back and
   update if I make any progress. As a quick dry run (and a hope for an easy fix!)
   I just tried swapping out the taxonomy from tags to categories, but that (of 
   course) didn’t work). Just noted your ‘e.g’ comment, going to try to see if I
   can figure it out.
 *  Thread Starter [adhanaraj](https://wordpress.org/support/users/adhanaraj/)
 * (@adhanaraj)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/multi-category-search/#post-3490139)
 * I absolutely lied, there definitely was an easy fix. Had to change $args[‘tag’]
   to $args[‘category’]. Thanks so much for your help, you are a god among men.
 * EDIT: Nope, I lied. Did not work 🙁
 *  Thread Starter [adhanaraj](https://wordpress.org/support/users/adhanaraj/)
 * (@adhanaraj)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/multi-category-search/#post-3490150)
 * Just running some more updates for you guys :).
 * I’ve got the search to work to an extent. It currently treats the three category
   boxes as an OR command, as opposed to a AND.
 * I’ve uploaded what I’ve done to a pastebin here. [http://pastebin.com/EMNmHfjS](http://pastebin.com/EMNmHfjS)
 * Any help would be great 🙂
 *  [agelonwl](https://wordpress.org/support/users/angelonwl/)
 * (@angelonwl)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/multi-category-search/#post-3490207)
 * I see now, maybe you can try to add new condition to filter empty categories
 * e.g.
 *     ```
       if ( $_REQUEST['segment'] != '-1' ){
   
       }
       ```
   
 *  Thread Starter [adhanaraj](https://wordpress.org/support/users/adhanaraj/)
 * (@adhanaraj)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/multi-category-search/#post-3490215)
 * Figured it out! Unfortunately had to change some of event_manager’s core files,
   so I’ll have to keep my eye out and replace it whenever EM updates.
 * Anyways, what I did was that I went into em-object.php (in /classes), and added
   two more key-value pairs to $super_defaults. I then went and duplicated anything
   to do with categories (minus wordpress terms) and changed them to the respective
   two new variables I wanted (products, segment).
 * Back to the event-list file I just passed the _REQUEST[‘variable’] onto their
   respect $variable.
 * Thanks for helping me out, really put me on the right path. 🙂
 *  [bentonwalker](https://wordpress.org/support/users/bentonwalker/)
 * (@bentonwalker)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/multi-category-search/#post-3490226)
 * Hey adhanaraj,
 * Would you mind pasting your php code from em-object.php and events-list.php to
   pastebin and posting the link? I’m trying to add two more category boxes like
   you did.
 * Thanks!
 * Benton
 *  Thread Starter [adhanaraj](https://wordpress.org/support/users/adhanaraj/)
 * (@adhanaraj)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/multi-category-search/#post-3490267)
 * Sure thing – the things that are changed are anything that have the words ‘product’
   or ‘segment’ in them 🙂
 * Disclaimer: This is probably not the best way of doing it, just the way that 
   worked for me.
 * I’ve split the pastebin into events-list, events-search, and then the entire 
   em-objects. Good luck!
 * [http://pastebin.com/dmtq9Qgs](http://pastebin.com/dmtq9Qgs)

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Multi-Category Search’ is closed to new replies.

 * ![](https://ps.w.org/events-manager/assets/icon-256x256.png?rev=1039078)
 * [Events Manager - Calendar, Bookings, Tickets, and more!](https://wordpress.org/plugins/events-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/events-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/events-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/events-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/events-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/events-manager/reviews/)

 * 9 replies
 * 3 participants
 * Last reply from: [adhanaraj](https://wordpress.org/support/users/adhanaraj/)
 * Last activity: [13 years, 2 months ago](https://wordpress.org/support/topic/multi-category-search/#post-3490267)
 * Status: resolved