Get Current Category ID
-
I have gone through every function to accomplish this with no luck. It seems that this function was deprecated. Can someone please give me the correct function to call the CURRENT CATEGORY ID.
The following do not work:
get_query_var('cat');
global $post; $categories = get_the_category($post->ID); var_dump($categories);
if (($actcat) && (is_single())) { global $wp_query; $cats = ''; foreach (get_the_category($wp_query->post->ID) as $catt) { $cats .= $catt->cat_ID.' '; } $cats = str_replace(" ", ",", trim($cats)); }
$cat_rows = $wpdb->get_results("SELECT term_id FROM wp_term_taxonomy WHERE taxonomy = 'category'"); foreach ($cat_rows as $cat_row) { if( is_category( $cat_row->term_id ) ){ $current_cat_wtf = $cat_row->term_id; } }
$category = get_queried_object();
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Get Current Category ID’ is closed to new replies.