Hi, I have a custom taxonomy called “sources” with several hundred terms and child terms. I would prefer to use the categories widget not the navigation menu widget because the latter requires manual creation (again, I have hundreds) whereas the former is incredibly convenient. The problem is that I don’t want to order my terms by creation date, name, slug or count. I need a custom order because my terms have names like Part 1, Part 11, Part 4A, Item 6 etc., and I created them at various times, and their count isn’t relevant, so none of the ordering options work for me. As I said I would really rather not create hundreds of menu items as an alternative. I have tried adding the custom term meta field “rank” and copied your “orderby.php” file into my child theme and added a “rank” option, but without success. Is there any way to accomplish what I want? See the sidebar menu at the url below. The top level is one of my child terms in the “sources” taxonomy and the other items are grandchildren. Thanks.
custom order for taxonomy terms
Resolved
OnPoint Plugins
Hi Leslie,
The easiest way to order your terms by a custom order, is to use a plugin like Simple Taxonomy Ordering. This will allow you to drag/drop the order of your terms and have the custom order reflected in the widgets.
Have a great day!
Leslie McCallum
Hi, the time it takes to manually order my terms is what I am trying to avoid, since I have hundreds of them. Otherwise, I could just use your navigation menu option instead of categories. Please let me know if there is any way to automate a custom order for taxonomy terms. Thanks.
OnPoint Plugins
Hi Leslie,
What would the order be based on?
Leslie McCallum
Hi, as noted in my original question, I would like to order them by a custom term meta field “rank.”
Leslie McCallum
I have tried this without success, in my child functions.php:
add_filter(‘advanced-sidebar-menu/menus/category/order-by’,’order_by_rank’, 10, 4);
function order_by_rank( $orderby, $widget_args, $widget_values, $menu_class ){
$orderby = ‘rank’; //orders sources by rank
return $orderby;
}
I have also tried copying your order_by.php file into my child theme folder and adding ‘rank’ as an option in place of ‘slug’ but my knowledge of php clearly isn’t strong enough. Thanks.
OnPoint Plugins
Hi Leslie,
WordPress does not support ordering terms by a meta field out of the box, but you may do so with some creative filters.
Assuming:
Have a great night!
Leslie McCallum
Wow, thank you so much. Just like that, because you were kind enough to write code for me, my problem is solved. Thanks again.