I am encountering a weird error when working with custom taxonomies. I am trying to get the name of categories of a custom taxonomy:
$terms = get_terms('taxonomy_name');
foreach ($terms as $term) {
$option = $term->name;
echo $option;
}
I'm not using the code into a template file, like page.php. I use it in functions.php but after the function which created the taxonomy. The code works fine if the taxonomy is a standard one like "category"(which displays regular post categories) but it's not working with custom ones.
I already tried to use $option = $term['name']; but with no luck. The error I get on this one is "Undefined index: name".
Any answer will be much appreciated!
Thank you! Madalin
$termsvariable is being altered somewhere aboveforeachor the$termis being altered insideforeach, otherwise the error message would have been different. – Mridul Aggarwal Nov 21 '12 at 10:01