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.

so my category got slug 'aeroplanes' and I need to get category names from it, but I can't get it with

$category = get_the_category($post->ID); 
echo $category[0]->cat_name;

cause it takes all posts from default category with category slug 'category'. How can I do that if I got category slug 'aerpolanes'?

share|improve this question
    
possible duplicate of categories with different slug –  Chip Bennett Oct 20 '11 at 19:47
add comment

1 Answer

See http://codex.wordpress.org/Function_Reference/get_term_by

The following code will work for your situation:

$cat = get_term_by( 'slug', 'aeroplane', 'category');
echo $cat->name;
share|improve this answer
    
Hello, it didn't help. It echoed nothing. + I got many subcategories in category that got slug aeroplane, and I need to echo those subcategory names. –  Y2ok Oct 20 '11 at 18:12
1  
@Y2ok - check the spelling in the answer by Russel Heimlich; make sure you use exactly the slug of your category ('aeroplanes'). you didn't directly ask for the child categories - please edit your question to make that clear. –  Michael Oct 20 '11 at 18:52
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.