WordPress.org

Forums

Events Manager
[resolved] Hide Category from Search Category Dropdown Menu (6 posts)

  1. deez
    Member
    Posted 1 year ago #

    Hi there,

    I've looked all over these forums and performed Google searches until my eyes bleed.

    I'm looking to simply hide specific categories from the Search function's Category Dropdown menu. Can someone inform me how this is possible?

    Thanks very much. Amazing plugin!

    https://wordpress.org/plugins/events-manager/

  2. caimin_nwl
    NetWebLogic Support
    Posted 1 year ago #

    Hi,

    Glad you're enjoying the plugin.

    The best way to do this would be to copy and modify the search categories template under/events-manager/templates/templates/search. This tutorial shows you how to do that in an upgrade safe way:

    http://wp-events-plugin.com/documentation/using-template-files/

    You'd then need to edit the wp_dropdown_categories function in the template to exclude the category IDs you don't want to display.

  3. deez
    Member
    Posted 1 year ago #

    Hi Caimin,

    Thanks for your help! I'm a little bit of an amateur with PHP. Can you help me figure out what code I would add to this file that would allow me to exclude categories in the dropdown menu by IDs?

    <?php $args = !empty($args) ? $args:array(); /* @var $args array */ ?>
    <!-- START Category Search -->
    <div class="em-search-category em-search-field">
    	<label><?php echo esc_html($args['category_label']); ?></label>
    	<?php
    		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', 'name' => 'category', 'hierarchical' => true, 'taxonomy' => EM_TAXONOMY_CATEGORY, 'selected' => $args['category'], 'show_option_none' => $args['categories_label'], 'class'=>'em-events-search-category'));
    		EM_Object::ms_global_switch_back(); //if switched above, switch back
    	?>
    </div>
    <!-- END Category Search -->
  4. caimin_nwl
    NetWebLogic Support
    Posted 1 year ago #

    The line you need to edit is the one that starts wp_dropdown_categories. Try using this line instead:

    wp_dropdown_categories(array( 'exclude' => '1,2','hide_empty' => 0, 'orderby' =>'name', 'name' => 'category', 'hierarchical' => true, 'taxonomy' => EM_TAXONOMY_CATEGORY, 'selected' => $args['category'], 'show_option_none' => $args['categories_label'], 'class'=>'em-events-search-category'));

    You'll see there's an extra exclude parameter at the start. Just change 1 and 2 to the category IDs you want to exclude. You can add as many more as you like, separating each with a comma.

    This might help:
    http://codex.wordpress.org/Function_Reference/wp_dropdown_categories

  5. deez
    Member
    Posted 1 year ago #

    Caimin,

    Thank you! Worked perfectly.
    You are a gentleman and a scholar.

  6. _SSS
    Member
    Posted 1 year ago #

    Hi,
    i want to exclude the event categories from search in my web. i had used search every-thing plugin for search so please help me how to exclude the event-categories from it.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic