Skip to content

Instantly share code, notes, and snippets.

@marcosnakamine
Created April 4, 2017 17:42
Show Gist options
  • Save marcosnakamine/9f9109c7cb5458e4df7d62fc9b1cae75 to your computer and use it in GitHub Desktop.
Save marcosnakamine/9f9109c7cb5458e4df7d62fc9b1cae75 to your computer and use it in GitHub Desktop.
WordPress - Get current categories
<?php
var_dump( get_the_category() ); // use in wp loop
/*
object(WP_Term)#306 (16) {
["term_id"]=>
int(49)
["name"]=>
string(6) "Markup"
["slug"]=>
string(6) "markup"
["term_group"]=>
int(0)
["term_taxonomy_id"]=>
int(49)
["taxonomy"]=>
string(8) "category"
["description"]=>
string(51) "Posts in this category test markup tags and styles."
["parent"]=>
int(0)
["count"]=>
int(6)
["filter"]=>
string(3) "raw"
["cat_ID"]=>
int(49)
["category_count"]=>
int(6)
["category_description"]=>
string(51) "Posts in this category test markup tags and styles."
["cat_name"]=>
string(6) "Markup"
["category_nicename"]=>
string(6) "markup"
["category_parent"]=>
int(0)
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment