Skip to content

Instantly share code, notes, and snippets.

@kythin
Created June 1, 2012 05:11
Show Gist options
  • Save kythin/2849016 to your computer and use it in GitHub Desktop.
Save kythin/2849016 to your computer and use it in GitHub Desktop.
Wordpress quick function to get current post's category id(s)
function getCurrentCatID(){
//Probably only works inside the_loop();
global $wp_query;
if(is_category() || is_single()){
$cat_ID = get_query_var('cat');
}
return $cat_ID;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment