Forums › Feature Requests › Need a Multi-Select Not a Dropdown or Checkbox
- This topic has 2 replies, 2 voices, and was last updated 7 years ago by
squints.
-
AuthorPosts
-
June 11, 2015 at 12:32 pm #38090
squints
MemberI need to display my listing categories within a multi-select field or a dropdown with multi-select ability but the only options I see are for a single select dropdown or checkbox (for premium members).
How can I add a “multi-select” option to the backend admin settings and have my categories display within a multi-select on the frontend search form? I had this same issue with another plugin called ‘Ultimate WP Query Search Filter’ and the plugin author provided me with the following awesome solution:
1234567891011121314151617181920212223242526272829303132#1. Add a multi-select option in the backendadd_filter('uwpqsftaxo_field', 'add_multiselect_admin');function add_multiselect_admin($fields){$fields['multiselect'] = 'Multi Select';return $fields;}#2. Add the field to the frontendadd_filter('uwpqsf_addtax_field_multiselect','multiselect_front','',11);function multiselect_front($type,$exc,$hide,$taxname,$taxlabel,$taxall,$opt,$c,$defaultclass,$formid,$divclass){$eid = explode(",", $exc);$args = array('hide_empty'=>$hide,'exclude'=>$eid );$taxoargs = apply_filters('uwpqsf_taxonomy_arg',$args,$taxname,$formid);$terms = get_terms($taxname,$taxoargs);$count = count($terms);$html = '<div class="'.$defaultclass.' '.$divclass.'" id="tax-select-'.$c.'"><span class="taxolabel-'.$c.'">'.$taxlabel.'</span>';$html .= '<input type="hidden" name="taxo['.$c.'][name]" value="'.$taxname.'"/>';$html .= '<input type="hidden" name="taxo['.$c.'][opt]" value="'.$opt.'"/>';$html .= '<select multiple id="tdp-'.$c.'" class="tdp-class-'.$c.'" name="taxo['.$c.'][term]">';if(!empty($taxall)){$html .= '<option selected value="uwpqsftaxoall">'.$taxall.'</option>';}if ( $count > 0 ){foreach ( $terms as $term ) {$selected = (isset($_GET['taxo'][$c]['term']) && $_GET['taxo'][$c]['term'] == $term->slug) ? 'selected="selected"' : '';$html .= '<option value="'.$term->slug.'" '.$selected.'>'.$term->name.'</option>';}}$html .= '</select>';$html .= '</div>';return $html;}I do not have the php/html knowledge or skills to modify the above code or create a new filter hook to create a multi-select option in GMW so I am really hoping that one of you plugin mods or authors could please provide a similar solution for GMW. Or if anyone thinks that they might be able to come up with a solution then you got mad skills!
June 13, 2015 at 11:39 pm #38215Eyal Fitoussi
MemberHi,
Unfortunately, at the moment I don’t have a solution to provide you with.I can provide you with the hooks that you will need to use but you will need to build the select output yourself in the back and front end self as well you will need to make sure you update the qp_query.
FYI,
The new version of the Premium Settings add-on supports the Chosen script. you can have the checkboxes taxonomies uses the Multiple Select feature which makes it very similar to the HTML multiselect.Let me know if you have any more questions.
June 15, 2015 at 6:41 am #38317squints
MemberHi Eyal,
Can you please provide me with the hooks I would need in order to set this up myself?
Also, would it be possible to copy the code used to display the multi-select in the “Friends” search form to the “Post” search form?
Thanks.
-
AuthorPosts
You must be logged in to reply to this topic.