Skip to content

Instantly share code, notes, and snippets.

@niran
Created July 20, 2009 20:33
Show Gist options
  • Save niran/150888 to your computer and use it in GitHub Desktop.
Save niran/150888 to your computer and use it in GitHub Desktop.
WordPress category object structure
<?php
# If you haven't played around with WordPress much and you're trying to find out what
# exactly this "category object" thing that's referenced in many places is. You might
# look for a category table in the database for some clues, but there isn't one. That's
# because WordPress uses "terms" to handle both categories and tags, each of which are
# "taxonomies". Looking in those tables will give you want you want, or you could just
# print a category object.
#
# More info: http://codex.wordpress.org/WordPress_Taxonomy
print_r(get_the_category());
Array
(
[0] => stdClass Object
(
[term_id] => 3 # category_id
[name] => News
[slug] => news
[term_group] => 0
[term_taxonomy_id] => 3 # identifies this "term" as a category
[taxonomy] => category
[description] =>
[parent] => 0
[count] => 215
[object_id] => 1262
# The following properties seem to be for compatibility with
# the older API, which doesn't seem to be documented anywhere either.
[cat_ID] => 3
[category_count] => 215
[category_description] =>
[cat_name] => News
[category_nicename] => news
[category_parent] => 0
)
)
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment