Output a Custom Taxonomy Archive by using Loop in WordPress

You can’t use a WordPress archive taxonomy page for a custom taxonomy as the custom terms are the archive – but you may want a sort of global taxonomy page that contains all the custom terms.

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 array $terms and then used in a foreach loop to output as a plain html unordered list.

This starts off simple just using the custom taxonomy term.

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/

You can then fully build out the loop and include other fields such as a custom image field used in the taxonomy term.

Leave all Comment