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:

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

  • 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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.