I have this simple snippet to retrieve the categories (taxonomies) of my Custom Post Type 'portfolio' I need to display each taxonomy but it displays all the categories.

I just saw this question Filter get_categories() for taxonomy term in WordPress and unfortunately I tried with no success.

    if ( have_posts() ) : while ( have_posts() ) : the_post(); 
    $catid = get_cat_id('Images');

    $categories=  get_categories('child_of='.$catid.'&orderby=name'); 
    foreach ($categories as $cat) {
    $input = '<li><a href="#" data-value="category-'.$cat->category_nicename.'">';
      $input .= $cat->cat_name;
      $input .= '</a></li>';
      echo $input;

Can you please guide me or give me a hint? Thanks so much.

  • categories (taxonomies) Category is taxonomy but other taxonomies are not categories. Could you please explain better what exactly you want to retrieve? Terms from several taxonomies?
    – Rarst
    Commented Jan 13, 2011 at 8:30
  • Can you give us an idea of what type of data/use-case you are working with? Like @Rarst I don't understand what you are trying to accomplish. Commented Jan 13, 2011 at 8:33
  • Sure let me explain better. I have a Custom Post Type in my custom post type I've created a Custom Taxonomy called 'Portfolio' with 1 category called 'Work' (parent) with 3 childs (Images, Video Production, Web Design). I want to display the Name of the child categories into a list. Sorry for my english
    – Ivor
    Commented Jan 13, 2011 at 8:44

1 Answer 1


First, you are mixing up terminology a bit. Portfolio is taxonomy, but Work, Images, etc are terms (not categories).

So you need to adjust functions for your taxonomy. Try this:


$catid = get_cat_id('Images');


$catid = get_term_by( 'name', 'Images', 'portfolio' );
$catid = $catid->term_id;


$categories = get_categories('child_of='.$catid.'&orderby=name'); 


$categories = get_categories('child_of='.$catid.'&orderby=name&taxonomy=portfolio');

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.