• Resolved Striknin

    (@marsbidon)


    Hi,

    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>
    	</select>
    	<!-- FIN Recherche Style principal -->
    	<?php
    }
    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;
    }
    add_filter('em_accepted_searches','my_em_styles_principal_accepted_searches',1,1);

    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 !

    https://www.ads-software.com/extend/plugins/events-manager/

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: Events Manager] Custom Attribute dropdown into search form’ is closed to new replies.