1

I've added a new taxonomy for the medias post type:

function register_taxonomy_for_images()
{
    register_taxonomy_for_object_type('category', 'attachment');
}

add_action('init', 'register_taxonomy_for_images');

And I've added a few categories via wordpress admin.How can I get an array of all the media categories that I added? I've tried get_categories() but it doesn't work.

1 Answer 1

0

Found the answer:

$categories = get_terms( 'category', array('hide_empty' => false) );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.