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'm running a query on a custom plugin to display all categories and put them into a dropdown (the select parts are outside the loop) which looks like this:

<?php
$ember_categories = get_categories();
foreach($ember_categories as $ember_category) {
    echo '<option value="' . $ember_category->cat_ID . '">' . $ember_category->name . '</option>';
}
?>

For some reason though, it's only returning my default category (Uncategorized) - even though there are six more added to the system (including one I added afterwards, just as a curiosity). I'm wondering whether I'm doing something glaringly wrong?

share|improve this question
1  
Doh! Should probably have thought of that. Thanks! –  George Pearce Jul 28 '11 at 22:45
    
Hey. Just saw that you removed the check mark for the solution. Could you please leave a comment on the answer, so it can be improved for later readers? –  kaiser Dec 27 '11 at 18:23
1  
Apologies - didn't mean to remove the check, I clicked it so it would accept your answer. Returned now, appreciate your help. –  George Pearce Dec 27 '11 at 20:52

1 Answer 1

up vote 6 down vote accepted

Try get_categories( array('hide_empty' => 0 ) );

share|improve this answer
    
Thanks Kaiser. great help. –  arslaan ejaz Jul 17 '13 at 21:04

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.