add_action('template_redirect','gs_get_cat_id'); function gs_get_cat_id(){ global $wp_query; $terms_post = get_the_terms( $post->cat_ID , 'product_cat' ); foreach ($terms_post as $term_cat) { $term_cat_id = $term_cat->term_id; echo $term_cat_id; } }
add_action('template_redirect','gs_get_cat_id'); function gs_get_cat_id(){ global $wp_query; $terms_post = get_the_terms( $post->cat_ID , 'product_cat' ); foreach ($terms_post as $term_cat) { $term_cat_id = $term_cat->term_id; echo $term_cat_id; } }