Last active
September 9, 2020 10:10
-
-
Save Korveld/61cfacf4bc62a776b3b80746f7c6bebf to your computer and use it in GitHub Desktop.
Get list of woocommerce categories
This file contains hidden or 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 | |
| $cat_args = array( | |
| 'orderby' => 'name', | |
| 'order' => 'asc', | |
| 'hide_empty' => false, | |
| // 'include' => 177 // (array|string) Array or comma/space-separated string of term ids to include. Default empty array. | |
| ); | |
| $product_categories = get_terms( 'product_cat', $cat_args ); | |
| if ( !empty($product_categories) ) { | |
| echo '<ul>'; | |
| foreach ($product_categories as $key => $category) { | |
| echo '<li>'; | |
| echo '<a href="' . get_term_link($category) . '" >'; | |
| echo $category->name; | |
| echo '</a>'; | |
| echo '</li>'; | |
| } | |
| echo '</ul>'; | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment