List multiple taxonomies from custom post type

WordPress question,

I have custom post type

Read More

3 taxonomies

and multiple terms within each taxonomy

The below code will spit out a list of terms within “Custom_Taxonomy”

How can I make it spit out the list from “Custom_Taxonomy2” within the same custom post type ?

$terms = get_terms( 'Custom_Taxonomy' );

echo '<ul>';

foreach ( $terms as $term ) {

    // The $term is an object, so we don't need to specify the $taxonomy.
    $term_link = get_term_link( $term );

    // If there was an error, continue to the next term.
    if ( is_wp_error( $term_link ) ) {
        continue;
    }

    // We successfully got a link. Print it out.
    echo '<li><a href="' . esc_url( $term_link ) . '">' . $term->name . '</a></li>';
}

echo '</ul>';

I’ve been trying the following solutions , but none of them work , im not much of a php coder. (Please dont give me a downvote , im trying here 🙂 )

$terms = get_terms( 'Custom_Taxonomy' AND 'Custom_Taxonomy2' );
$terms = get_terms( 'Custom_Taxonomy' || 'Custom_Taxonomy2' );
$terms = get_terms( 'Custom_Taxonomy' && 'Custom_Taxonomy2' );
$terms = get_terms( 'Custom_Taxonomy', 'Custom_Taxonomy2' );
$terms = get_terms( 'Custom_Taxonomy' 'Custom_Taxonomy2' );

Related posts

1 comment

  1. To fetch the results for multiple taxonomies you just pass a array into the name field

      $terms = get_terms( array( 'Custom_Taxonomy', 'Custom_Taxonomy2'), $args ); 
    

Comments are closed.