3

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?

3
  • 1
    Doh! Should probably have thought of that. Thanks! Commented Jul 28, 2011 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
    Commented Dec 27, 2011 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. Commented Dec 27, 2011 at 20:52

1 Answer 1

7

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

0

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.