How to list custom taxonomy categories?

To get a list of your custom taxonomies, you can use the get_terms() function to create a loop:

// Get the taxonomy's terms
$terms = get_terms(
    array(
        'taxonomy'   => 'your-taxonomy',
        'hide_empty' => false,
    )
);

// Check if any term exists
if ( ! empty( $terms ) && is_array( $terms ) ) {
    // Run a loop and print them all
    foreach ( $terms as $term ) { ?>
        <a href="https://wordpress.stackexchange.com/questions/287501/<?php echo esc_url( get_term_link( $term ) ) ?>">
            <?php echo $term->name; ?>
        </a><?php
    }
} 

Leave a Comment

tech