I have created a custom post type named 'projects' with link custom taxonomy named 'projects'. I have added the five different project categories with this project taxonomy with two level of hierarchy custom post type ui. I tried to find function to get these five categories with taxonomy name 'projects' but i did not get the solution. Can anyone help me out how to get the list of these categories created with taxonomy named 'projects'. Any help will be appreciated.

Thanks in advance

1 Answer 1


You will want to use get_terms. The following code show you how to access the terms. Please see the Codex page for get_terms for more information about the args that you can send to the function. I also show all of the data that is returned in the array of objects.

// Set your args
$args = array(
    'hide_empty' => 0   // Show terms that are not associated with any posts

// Get the terms
$projects = get_terms('projects', $args);

// Loop through and use terms
foreach($projects as $project)
    echo 'Term ID ' . $project->term_id;
    echo 'Name: ' . $project->name;
    echo 'Slug: ' . $project->slug;
    echo 'Term Group ' . $project->term_group;
    echo 'Term Taxonomy ID: ' . $project->term_taxonomy_id;
    echo 'Taxonomy: ' . $project->taxonomy;
    echo 'Description ' . $project->description;
    echo 'Parent: ' . $project->parent;
    echo 'Count: ' . $project->count;
  • Thank you so much it worked .. Actually I tried this one too but did not work may be there was some problem with my code... Thanks again
    – user478
    Commented Aug 23, 2011 at 2:54
  • The hide_empty=0 can make or break you. Intuitively, most people expect this to automatically return all of the terms; however, by default it only gets terms that are associated with posts.
    – tollmanz
    Commented Aug 23, 2011 at 14:16

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.