Events Manager
[resolved] Custom Attribute dropdown into search form (4 posts)

  1. marsbidon
    Posted 3 years ago #


    I'm posting this question because I've don't found the solution neither in Google nor in Events manager's documentation.

    For my events, I've defined an attribute called "style_principal".
    I can display it by using the shortcode #_ATT{style_principal}

    I want to create a new dropdown into search form on the main events page for searching by this attribute.

    I've tried this code (inspiring myself by documentation / tutorial) :

    function my_em_styles_principal_search_form(){ ?>
    	<!-- DEBUT Recherche Style principal -->
    	<select name="style_principal">
    		<option value=''>Tous les styles</option>
    		<option value="chanson" <?php echo ($_POST['style_principal'] == "chanson") ? 'selected="selected"':''; ?>>Chanson</option>
    		<option value="eclectique" <?php echo ($_POST['style_principal'] == "eclectique") ? 'selected="selected"':''; ?>>Eclectique</option>
    		<option value="electro" <?php echo ($_POST['style_principal'] == "electro") ? 'selected="selected"':''; ?>>Electro</option>
    		<option value="festival" <?php echo ($_POST['style_principal'] == "festival") ? 'selected="selected"':''; ?>>Festival</option>
    		<option value="groove" <?php echo ($_POST['style_principal'] == "groove") ? 'selected="selected"':''; ?>>Groove</option>
    		<option value="jazz" <?php echo ($_POST['style_principal}'] == "jazz") ? 'selected="selected"':''; ?>>Jazz</option>
    		<option value="musiques-monde" <?php echo ($_POST['style_principal'] == "musiques-monde") ? 'selected="selected"':''; ?>>Musiques du Monde</option>
    		<option value="reggae" <?php echo ($_POST['style_principal'] == "reggae") ? 'selected="selected"':''; ?>>Reggae</option>
    		<option value="rock" <?php echo ($_POST['style_principal'] == "rock") ? 'selected="selected"':''; ?>>Rock</option>
    	<!-- FIN Recherche Style principal -->
    add_action('em_template_events_search_form_ddm', 'my_em_styles_principal_search_form');
    function my_em_styles_principal_accepted_searches($searches){
    	$searches[] = 'style_principal';
    	return $searches;

    This code displays the dropdown but when I want to search by attributes, nothing happens, the page displays all events.

    Can anyone help me please? I've spent so much time searching how to do this...

    Thanks !


  2. agelonwl
    Posted 3 years ago #

  3. marsbidon
    Posted 3 years ago #

    I've already seen and test all in this post. My attribute isn't a field like a taxonomy, I need a select list where the user can only choose one option.

    If there is any possibility with the post you wrote, I could try but at this time it don't help me ...

    Have any other idea ? Please ?

  4. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 3 years ago #

    your attribute is a postmeta, so you'll want to join the wp_postmeta table and look for meta_key = 'style_principal'

    to do this, yo'll need to hook into the conditional hook as explained here in the first snippet - http://wp-events-plugin.com/tutorials/create-your-own-event-scope/

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Events Manager
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic