KodeFor.Me
KodeFor.Me

Reputation: 13521

WordPress, get_categories, taxonomy

I have a very simple question that is not answered on WordPress Codex.

The get_categories() function get an option for taxonomies. What I like to ask is, can I pass more than one taxonomies like that:

get_categories(
    array(
        'taxonomies' => 'category,my_custom_taxonomy'
    )
);

Upvotes: 0

Views: 1866

Answers (1)

Chris_O
Chris_O

Reputation: 3444

The get_categories function only allows a string (1 taxonomy) to be entered for the taxonomy arg.

You can use get_terms which allows an array of taxonomies.

$args = array( 'taxonomies' => array( 'tax_1', 'tax_2', 'tax_3') );

$categories = get_terms ( $args );

for each ( $categories as $cat ) :

  var_dump( $cat );

endforeach;

Upvotes: 1

Related Questions