Getting categories to change appropriately when using $cat = ‘ ‘;
If you are in a category context this should work and and you’ll get the correct catID to work with. function getCurrentCatID(){ global $wp_query; if(is_category()){ $cat_ID = get_query_var(‘cat’); } return $cat_ID; } $catID = getCurrentCatID();