You will need to add term meta to your categories. In this metafield you will store the string or number that you want to use as a base for your custom order (tutorial). Let’s say you have generated a meta field called my_cat_meta
which holds integers that say in which order you want them to be displayed.
Now you can pass this metakey to wp_list_categories
. This function ultimately relies on get_terms
, which explains which arguments the function can take. You can limit the search to terms that have the metakey defined and order according to that metakey. This amounts to:
$args = array (
'title_li' -> '',
'meta_key' -> 'my_cat_meta',
'orderby'-> 'meta_key');
wp_list_categories ($args);
A slightly hacky way would be to use the ‘description’ field that is a default field in WP categories. Many themes don’t display it, so you could use it to store metadata. In that case you could skip building your own metafield and use:
$args = array (
'title_li' -> '',
'orderby'-> 'description');
wp_list_categories ($args);