Order of the Categories in my Blog sidebars

Good evening,
I’d like to change the order of my categories in the main sidebar, which is the blog’s sidebar.
At this moment the order is an alphabetical order. How can I change that order?
Thank you so much.
Best regards

Hi There,

To change the other of widget categories, please add this custom code under functions.php file locates in your child theme:

add_filter( 'widget_categories_args', 'change_default_order_cat_widget', 10, 2 );
function change_default_order_cat_widget($cat_args, $instance){
	$c = ! empty( $instance['count'] ) ? '1' : '0';
	$h = ! empty( $instance['hierarchical'] ) ? '1' : '0';
	$cat_args = array(
		'orderby'      => 'count',
		'show_count'   => $c,
		'hierarchical' => $h,
	);
	return $cat_args;
}

The orderby value available is: 'name', 'slug', 'term_group', 'term_id', 'id', 'description', 'parent'.

For more information, please take a look at this:

https://developer.wordpress.org/reference/classes/wp_term_query/__construct/

Hope that helps and thank you for understanding.

Thank you, Thai. I understand. simply I hoped some mask options more, because I use wordpress.com and I don’t know at the moment how manage my blog in my local directory inside my PC. I’m going to study how to do this in the next days.
Thank you a lot for your help about functions.php.
Best regards.

You’re most welcome! With Wordpress.com, you’re more likely going to extract your child theme in your PC, edit it, and zip it again and install it through admin (given that you must first delete the existing child theme to be able to install the new one).

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.