Your address will show here +12 34 56 78

Home Forums WP RESIDENCE – Real Estate WordPress Theme FORUM property_categories.php from dropdown single select to multiple

This topic contains 4 replies, has 3 voices, and was last updated by  Vess 2 years, 1 month ago.

  • Author
    Posts
  • #104658

    Vess
    Participant

    Hello

    I have changed the below code for WP RESIDENCE file property_categories.php from dropdown single select to multiple selection, but now it is not submitting and receiving any values from front end.
    Please give a solution.

    <?php
    /**
    * echo off.
    * changed name (adding “[]”)
    */
    $args = array(
    ‘class’ => ‘select-submit2′,
    ‘hide_empty’ => false,
    ‘selected’ => $prop_action_category_selected,
    ‘name’ => ‘prop_action_category[]’,
    ‘id’ => ‘prop_action_category_submit’,
    ‘orderby’ => ‘NAME’,
    ‘order’ => ‘ASC’,
    ‘show_option_none’ => __(‘None’,’wpestate’),
    ‘taxonomy’ => ‘property_action_category’,
    ‘hierarchical’=> true,
    ‘echo’ => 0,
    );

    /** get the dropdown **/
    $dropdown = wp_dropdown_categories( $args );

    /** insert “multiple” using str_replace **/
    $multi = str_replace( ‘<select’, ‘<select multiple ‘, $dropdown );

    /** output result **/
    echo $multi;?>

    • This topic was modified 2 years, 6 months ago by  Vess.
    • This topic was modified 2 years, 6 months ago by  Vess.
  • #115639

    mithril
    Participant

    Hello,

    Did you get the code to work? I’m having the same issue.

    • #116167

      Vess
      Participant

      I am on the same stage, as written above.

  • #117866

    Anna
    Keymaster

    By adding multiple you allow only for multiple selects on that particular select. But that does not mean it is saved into database with multiple values, or is interpreted as multiple values in the same page.

    The code is not working probably because the post variable is now an Array and you need to save it like one. Then you need to check every category and see if is inside the array you just saved and marked as selected. In the same page you should do a print of the variable and see if it saved correctly.

    It’s possible this development link will help with more technical steps: http://wordpress.stackexchange.com/questions/170316/multiple-checkboxes-metabox

  • #117903

    Vess
    Participant

    Thank you Anna for the hint.

You must be logged in to reply to this topic.