If you know nothing about Wordpress but know how to display everything stored in an php array (at least in my case) - please answer. I'll appreciate!
I've an PHP array that keeps lists of categories. But I have no idea how to display its contents.
This code:
$category = get_the_category();
echo $category;
Outputs:
Array
What I want to do is to display first item in the array.
I've also tried:
echo $category[0]->cat_name
echo $category[1]->cat_name
Where the cat_name was "cat_name", "Folio" (my custom post type name), "type", "types" and "my_folio_cat". Everything outputs nothing (even not "Array" text).
I'm registering taxonomy like that:
register_taxonomy("my_folio_cat", array("folio"), array("hierarchical" => true, "label" => "Type", "singular_label" => "Type", "rewrite" => true));
get_the_category
,$category[0]->cat_name
should do it. Tryvar_dump($category)
to see the structure of the variable, and it would help to edit your post and add that info here. It's not just arrays here, just to note - some of this info is stored in a PHP object. – JAL Dec 6 '10 at 16:57name
instead ofcat_name
(which is deprecated, and only currently implemented for back-compat) – TheDeadMedic Dec 6 '10 at 18:36