WordPress.org

Ready to get started?Download WordPress

Forums

get_terms() child_of and ORDERBY (1 post)

  1. fagnerguima
    Member
    Posted 1 year ago #

    When i use get_terms without child_of the function respect the orderby, but when i add child_of the result ignore any params orderby. I think that is a Code bug in WP.

    Example

    Orderby Work:

    $terms = get_terms("localidade", array(
    		'orderby' => 'name',
    		'order' => "ASC"
    ));
    foreach ( $terms as $term ) {
    	echo "<li><a href='" . get_term_link($term->name,'localidade') . "'>" . $term->name . "</a></li>";
    }

    Don't work:

    $terms = get_terms("localidade", array(
    		'orderby' => 'name',
    		'order' => "ASC",
    		'child_of' => 22
    ));
    foreach ( $terms as $term ) {
    	echo "<li><a href='" . get_term_link($term->name,'localidade') . "'>" . $term->name . "</a></li>";
    }

Topic Closed

This topic has been closed to new replies.

About this Topic