• Hello,

    I hope that this is easy question, I’d like to add dropdown menu to “City” field of accommodation search form, wordpress theme wprentals has “City” category where is possible to add cities but problem is that people search various versions so it is better to offer dropdown menu with available cities for easy and safe search.

    Code is located in wordpress theme file shortcodes.php , part of it related to “advanced search function” is extracted to shortcodes.txt file which can be viewed at the following link:

    https://zadarapartments.com/shortcodes.txt

    I’ll much appreciate any help with additional code in order to add dropdown menu in search form, I’ll provide any additional information. (On the website search form “City” field is currently “display: none”).

    Thank you!

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator threadi

    (@threadi)

    What plugin are you using to build this form? You should contact their support team with your question.

    Moderator bcworkz

    (@bcworkz)

    What threadi said ^^^ 🙂
    The code you linked to makes a call to function wpestate_get_city_select_list(). There must be some straight forward way for you to define the content returned by this function. Their support team should be able to tell you how to do so.

    Thread Starter pomalo

    (@pomalo)

    @bcworkz thank you for your respond, as I mentioned code is from wordpress theme not some plugin, theme authors are very busy so they do not do custom work.

    Theme has a version of dropdown menu for cities category on this page:

    https://zadarapartments.com/apartments-zadar-croatia-holiday-rentals/

    In help_functions.php is reference to function wpestate_get_city_select_list, code:

    ////////////////////////////////////////////////////////////////////////////////
    /// show hieracy city
    ////////////////////////////////////////////////////////////////////////////////
    if( !function_exists('wpestate_get_city_select_list') ):
    /* function wpestate_get_city_select_list($args){
    $select_city_list = '<li role="presentation" data-value="all" data-value2="all">'. esc_html__( 'All Cities','wpestate').'</li>';
    $taxonomy = 'property_city';
    $tax_terms_city = get_terms($taxonomy,$args);

    foreach ($tax_terms_city as $tax_term) {
    $string = wpestate_limit45 ( sanitize_title ( $tax_term->slug ) );
    $slug = sanitize_key($string);
    $select_city_list .= '<li role="presentation" data-value="'.$tax_term->slug.'" data-value2="'.$slug.'">'. ucwords ( urldecode( $tax_term->name) ).' ('.$tax_term->count.')'.'</li>';
    $select_city_list .= wpestate_hierarchical_category_childen($taxonomy, $tax_term->term_id,$args );
    }
    return $select_city_list;
    }*/
    function wpestate_get_city_select_list($args){
    $categ_select_list = '<li role="presentation" data-value="all" data-value2="all">'. __('All Cities','wpestate').'</li>';
    $taxonomy = 'property_city';
    $categories = get_terms($taxonomy,$args);
            foreach ($categories as $categ) {
    $string = wpestate_limit45 ( sanitize_title ( $categ->slug ) );
    $slug = sanitize_key($string);
    $received = wpestate_hierarchical_category_childen($taxonomy, $categ->term_id,$args );
    $counter = $categ->count;
    if( isset($received['count']) ){
    $counter = $counter+$received['count'];
    }

    $categ_select_list .= '<li role="presentation" data-value="'.$categ->slug.'" data-value2="'.$slug.'">'. ucwords ( urldecode( $categ->name ) ).' ('.$counter.')'.'</li>';
    if(isset($received['html'])){
    $categ_select_list .= $received['html'];
    }

    }
    return $categ_select_list;
    }
    endif;

    Function wpestate_get_city_select_list is mentioned in 2 more PHP files but I think above code is related to cities category dropdown menu on above page, perhaps it can be used to add category dropdown menu also to search form?

    Moderator threadi

    (@threadi)

    You are using the commercial theme WpRentals. No one here has access to it, and no one can purchase it just to help you. Therefore, questions regarding commercial matters are not permitted here in the forum. You have two options:

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

You must be logged in to reply to this topic.