WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

Found the answer:

$categories = get_terms( 'category', array('hide_empty' => false) );
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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