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.

Well, I'm using my own taxonomy for custom post type. It looks like this:

register_taxonomy("our_gallery", array("gallery"), array("hierarchical" => true, "label" => "Types", "singular_label" => "Type", "rewrite" => true));

I have created a few "types"/categories in my admin panel like "Black and white", "Landscapes" and so forth...

Anyways I can't figure out how to get these categories out? I mean - display them on my gallery page just next to gallery items?

I've tried:

  <?php $cat = get_the_category();
    var_dump($cat); ?>

And it displays an empty array - "array(0) { }". How to get access to my own categories? get_the_category('our gallery') and ('gallery') also gives an empty array...

Thanks a lot :)

share|improve this question
    
This question has been answered quite a few times now - should we be pointing to existing answers instead of answering it again? –  anu Dec 9 '10 at 14:10
    
@anu if you know a duplicate question please include a link to it in comment. Users with 500+ rep can cast close votes and cite duplicate as reason, I just can't remember exact match to this one myself. :) –  Rarst Dec 9 '10 at 14:36
    
This: wordpress.stackexchange.com/questions/4291 is pretty much the same question –  anu Dec 9 '10 at 17:24

2 Answers 2

up vote 6 down vote accepted

I think you are getting confused by terminology here.

Category is a taxonomy. Specific categories you create are terms.

our_gallery is taxonomy. Landscapes is term. our_gallery is not category. It is its own taxonomy and has nothing to do with category taxonomy.

get_the_category() function explicitly fetches terms of category taxonomy.

To get terms of our_gallery taxonomy you need more generic function get_the_terms().

share|improve this answer
    
Got it! Can you help me with getting 'landscape' out o this? array(1) { [17]=> object(stdClass)#378 (10) { ["term_id"]=> string(2) "17" ["name"]=> string(5) "Image" ["slug"]=> string(5) "image" ["term_group"]=> string(1) "0" ["term_taxonomy_id"]=> string(2) "19" ["taxonomy"]=> string(18) "our_gallery" ["description"]=> –  Wordpressor Dec 9 '10 at 14:16
1  
Please add any code and followup to your question and markup it as such. Comments are no good for that. –  Rarst Dec 9 '10 at 14:38
2  
You can use the_terms($post->ID, 'our_gallery') to automatically display a comma separated list for the current post. –  TheDeadMedic Dec 9 '10 at 14:38
    
But it still displays a link, not paragraph... –  Wordpressor Dec 9 '10 at 21:00

Maybe you should use following statement to get categories of a taxonomy:

$taxonomy  = 'your-taxonomy-name';
$tax_terms = get_terms($taxonomy, array('hide_empty' => false));
share|improve this answer

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.