Viewing 9 replies - 1 through 9 (of 9 total)
  • Hi Claudio,

    Take a look at this snippet:
    http://pastebin.com/WhHKd6rH

    Although it’s intended to add a countries filter, you should be able to use location_town instead of instead of location_country.

    Thread Starter clauds54

    (@clauds54)

    Tanks caimin it seams what i am looking for.
    I am not a programmer as metioned in a past post, can i use the snippet
    in a custom template ?
    Ciao
    Claudio

    Thread Starter clauds54

    (@clauds54)

    Ps.
    Since i am using location_town must i put all the towns in:$allowed_countries = array("US","CN"); ?

    Thread Starter clauds54

    (@clauds54)

    Ok this is what i did ` <!– START Country Search –>
    <div class=”em-search-country em-search-field”>
    <label><?php echo esc_html(get_option(‘dbem_search_form_town_label’)); ?></label>
    <select name=”Citta” class=”em-search-town em-events-search-town “>
    <option value=”><?php echo esc_html(get_option(‘dbem_search_form_town_label’)); ?></option>
    <?php
    //get the counties from locations table
    global $wpdb;
    $towns = em_get_towns();
    $em_towns = $wpdb->get_results(“SELECT DISTINCT location_town FROM “.EM_LOCATIONS_TABLE.” WHERE location_town IS NOT NULL AND location_town != ” AND location_status=1 ORDER BY location_town ASC”, ARRAY_N);
    $ddm_towns = array();
    foreach($em_towns as $em_town){
    $ddm_towns[$em_town[0]] = $towns[$em_town[0]];
    }
    asort($ddm_towns);
    $allowed_towns = array(“Napoli”,”Pozzuoli”);
    foreach( $ddm_towns as $town_code => $town_name ):
    //we’re not using esc_ functions here because values are hard-coded within em_get_countries()
    if ( in_array($town_code,$allowed_towns) ){
    ?>
    <option value=”<?php echo $town_code; ?>” <?php echo (!empty($_REQUEST[‘town’]) && $_REQUEST[‘town’] == $town_code) ? ‘selected=”selected”‘:”; ?>><?php echo $town_name; ?></option>
    <?php } ?>
    <?php endforeach; ?>
    </select>
    </div>
    <!– END Country Search –>`
    Changing all countries to towns and all countrie to town
    + plus changed allowed coutries inserting two towns.
    But all i get is a serch form that says City/Town then a dropdown that only shows this enty City/Town an thats it.
    What am i doing wrong ?

    Sorry, I think I misread your original question. There’s a much easier way 🙂

    Go to Events > Settings > Formatting > Search Form and set Show towns/cities to Yes.

    Thread Starter clauds54

    (@clauds54)

    No that works fine in my event page, but searches for events in a City/town.
    What i need is a search filter that shows all locations (not events) in a specific town because not all locations have events going on but i need to show them anyway.

    If you think it might help i can past my custom template some where.
    Grazie caimin
    Claudio

    You can use the [locations_list] shortcode to do this:
    http://wp-events-plugin.com/documentation/shortcodes/

    You’d need to add in the one of the location attributes to display event in each town:

    http://wp-events-plugin.com/documentation/event-search-attributes/

    Thread Starter clauds54

    (@clauds54)

    I think i do not undesrtand exactly what to do.
    I have created a regular WP page and put this in it:<ul>[locations_list]<li>#_LOCATIONTOWN</li>[/locations_list]</ul>this is what i get:
    TOWN LIST
    Napoli
    Napoli
    Napoli
    Napoli
    Napoli
    Pozzuoli
    Salerno
    Napoli
    Napoli
    Napoli

    what i would like is someting like:
    Choose the town you wish to see the locations (with or without events)
    -a dropdown of towns – and once one town is chosen the the template will filter for locations that only are in that town.
    is’ probably a very simple thing to do but you must excuse me caimin but i do not understand how to implement it.

    Thank you for your time and cutresy.
    Claudio

    Plugin Support angelo_nwl

    (@angelo_nwl)

    have you tried Events > Settings > Formatting > Search Form ? or template file events-manager/templates/templates/locations-search.php

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

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Filtering location by City Form’ is closed to new replies.