WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. Sami kamal
    Member
    Posted 1 year ago #

    Hello,

    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?

    http://wordpress.org/extend/plugins/wp-query-search-filter/

  2. TC.K
    Member
    Plugin Author

    Posted 1 year 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
    Member
    Posted 1 year 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.

    thanks

  4. TC.K
    Member
    Plugin Author

    Posted 1 year 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

Tags

No tags yet.