Skip to content

Instantly share code, notes, and snippets.

@nlssn
Last active April 23, 2023 10:41
Show Gist options
  • Save nlssn/adb944b4ffe369977ddad5b7d47eb23a to your computer and use it in GitHub Desktop.
Save nlssn/adb944b4ffe369977ddad5b7d47eb23a to your computer and use it in GitHub Desktop.
Dirty solution to wp_list_categories not respecting the order of manually sorted WooCommerce categories
<?php
// Get the IDs of all product categories
$categories_args = array(
'taxonomy' => 'product_cat',
'fields' => 'ids',
);
$categories = get_terms( $categories_args );
// Get the previously fetched categories, and output them in a nicely formatted list
$list_args = array(
'taxonomy' => 'product_cat',
'title_li' => __('Title', 'domain'),
'include' => $categories,
'orderby' => 'include',
);
wp_list_categories( $list_args );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment