I am trying to display the categories with the get_terms function with the following code:
$categories = get_terms( 'category');
$categories_count = count($categories);
for ($i = 0; $i < $categories_count; $i++) {
echo($i . $categories[$i]->name.' <br /> ');
}
But for some reason doesnt display all the categories, a couple of them are missing uncategorized and something else, this is what I see on the screen when i run this code:
- 0 Chairs
- 1
- 2 Interiors
- 3
- 4 Featured
Thanks very much,
You can try
get_categories()instead ofget_terms(). This is how you should do it:Just give it a shot …