Support » Plugin: Ultimate WP Query Search Filter » Order Parent Child Categories as indented checkboxes

Viewing 6 replies - 1 through 6 (of 6 total)
  • Sorry the list didn’t display properly

    As Follows:

    Animals (Parent Category)
    –Dolphin (Child Category)
    –Penguin

    Plugin Author TC.K

    (@wp_dummy)

    You can use ‘uwpqsf_tax_field_checkbox’ filter to customize the checkbox layout for taxonomy. But it could be complicated.

    The field using following script to generate the html field:

    $html  = '<div class="'.$defaultclass.' '.$divclass.' tax-check-'.$c.' togglecheck"><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.'">';
    				if(!empty($taxall)){
    				$html .= '<label><input type="checkbox" id="tchkb-'.$c.'" name="taxo['.$c.'][call]" class="chktaxoall" >'.$taxall.'</label>';
    				}
    				foreach ( $terms as $term ) {
    				$value = $term->slug;
    				$html .= '<label><input type="checkbox" id="tchkb-'.$c.'" name="taxo['.$c.'][term][]" value="'.$value.'" >'.$term->name.'</label>';
    				}
    				$html .= '</div>';

    As you can see there are essential part in the field such as the hidden fields and input name 'taxo['.$c.'][term][]'

    To use the filter:

    add_filter('uwpqsf_tax_field_checkbox','my_cus_check_display','',12);
    function my_cus_check_display($html ,$type,$exc,$hide,$taxname,$taxlabel,$taxall,$opt,$c,$defaultclass,$formid,$divclass){
    {
    //there are 12 parameters in the function, so you can refer to above default to customize what you want. eg.
    $eid = explode(",", $exc);
    $args = array('hide_empty' => $hide, 'orderby' => 'term_group','exclude'=>$eid ); // group the terms
    $terms = get_terms($taxname,$taxoargs);
    
    $html  = '<div class="'.$defaultclass.' '.$divclass.' tax-check-'.$c.' togglecheck"><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.'">';
    				if(!empty($taxall)){
    				$html .= '<label><input type="checkbox" id="tchkb-'.$c.'" name="taxo['.$c.'][call]" class="chktaxoall" >'.$taxall.'</label>';
    				}
    				foreach ( $terms as $term ) {
    				$value = $term->slug;
    				$html .= '<label><input type="checkbox" id="tchkb-'.$c.'" name="taxo['.$c.'][term][]" value="'.$value.'" >'.$term->name.'</label>'; //here is where you want to customize
    				}
    				$html .= '</div>';
    
    return $html;
    }

    Hi TC.K,

    Thanks for responding. I’m currently trying to understand the code related to the changes you mentioned.

    I’m a bit confused as to which plugin files to add it to. Could you point me in the right direction?

    Much appreciated

    Plugin Author TC.K

    (@wp_dummy)

    It’s filter, so you can add it on your theme’s functions.php

    Hi TC.K,

    I’ve added the code you provided to the functions.php file but i’m a not sure as to why it’s not working. Basically, only one category (uncategorised) displays even though I do not have any custom taxonomies.

    Any suggestions welcome,

    Paul

    Plugin Author TC.K

    (@wp_dummy)

    Not sure what is it. But you can turn the wp debug on to see if there any errors.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Order Parent Child Categories as indented checkboxes’ is closed to new replies.