Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

<?php
    query_posts("post_type=portfolio");
    if ( have_posts() ) : while ( have_posts() ) : the_post(); 
    $catid = get_cat_id('Images');
?>

<?php 
    $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.

share|improve this question
    
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 Jan 13 '11 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. –  MikeSchinkel Jan 13 '11 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 Jan 13 '11 at 8:44
add comment

1 Answer

up vote 0 down vote accepted

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:

Replace:

$catid = get_cat_id('Images');

Becomes:

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

And:

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

Becomes:

$categories = get_categories('child_of='.$catid.'&orderby=name&taxonomy=portfolio');
share|improve this answer
    
Thanks so much Rarst, I think I'm "on the road" –  Ivor Jan 14 '11 at 3:36
add comment

Your Answer

 
discard

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.