Site icon Hip-Hop Website Design and Development

Change default ordering of taxonomy phrases – pre_get_terms

I needed to alter the default taxonomy phrases order by its ‘term_order’ worth as a substitute of ‘identify’ in admin aspect. So I attempted one thing like under. But it surely does not work and php reminiscence exhaust.

perform uc_order_term( $wp_query ) {
    $wp_query->question(
        array(
            'taxonomy' => 'class',
            'orderby' => 'term_order',
            'order' => 'ASC'
        )
    );
}
add_action( 'pre_get_terms', 'uc_order_term');

Nevertheless in comparable approach I attempted to kind posts by menu_order and it really works.

perform uc_order_post( $wp_query ) {

            $wp_query->set('orderby', 'menu_order');
            $wp_query->set('order', 'ASC');

}
add_action( 'pre_get_posts', 'uc_order_post', 1 );