Created
June 1, 2012 05:11
-
-
Save kythin/2849016 to your computer and use it in GitHub Desktop.
Wordpress quick function to get current post's category id(s)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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