Last active
April 23, 2023 10:41
-
-
Save pixelregn/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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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