0

I am using get terms to return a list of terms within a custom taxonomy. It's returning an array but it starts at index 4.

How do I get it to start at 0 like normal?

1 Answer 1

0

Run get_terms like this:

var_dump(get_terms('category',array('hide_empty'=>false)));

And then like this:

var_dump(get_terms('category'));

You should be able to infer what is happening. The first should return the zero based array you expect, with neatly numbered keys. The second does not. The only difference being the hide_empty argument.

If you really must have a zero based array just pass the results though PHP's array_values:

var_dump(array_values(get_terms('category')));

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.