WP Query Search Filter
how to order a dropdown by parent terms? (4 posts)

  1. Sami kamal
    Posted 3 years ago #


    I'm using the plugin to make a multi-dropdown taxonomies search. The first dropdown has categories with parent and child terms all showing inside this select field. I want to make child terms show under their parent terms by adding left padding. I added this code inside the foreach() in line 212 in /wp-query-search-filter.php file:

    if ( 0 == $term->parent )  {
    	$pad = '';
    	} else {
    		$pad = '   ';
    echo '<option value="'.$term->slug.'" '.$selected.' class="'.$class.'">'.$pad.' '.$term->name.'</option>';

    this adds left space to child terms, but the problem is all parent and child terms show in the ASC order. It doesn't show child terms inside their parent terms.

    any help?


  2. TC.K
    Plugin Author

    Posted 3 years ago #

    Maybe you should try adding "orderby" => "slug" in line 206 (in the get terms function).

    Or you should see this this example .

    Hope this helps

  3. Sami kamal
    Posted 3 years ago #

    ok I fixed it with this in line 206:

    $terms = get_terms($v['taxname'],'hide_empty='.$v['hide'].'&orderby=term_group');

    I think this should be in core plus the extra pad for child terms.


  4. TC.K
    Plugin Author

    Posted 3 years ago #

    @Sami kamal,
    yep...will consider to add it in future upgrade.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic


No tags yet.