Skip to content

Output a Custom Taxonomy Loop in WordPress

Here is a custom taxonomy loop code snippet, which allows you to output a set of custom taxonomy terms using the get_terms object and a foreach loop.

In the above, a custom taxonomy named custom_taxonomy_name is assigned to the variable $terms and then used in a foreach loop to output as a plain html unordered list. One of the parameters passed in is to hide any terms which have no linked posts with the hide_empty value, more parameters can be found at https://developer.wordpress.org/reference/classes/wp_term_query/__construct/

Leave a Comment





Scroll To Top