Skip to content

Instantly share code, notes, and snippets.

@nickkuijpers
Created February 24, 2015 08:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickkuijpers/d3f5723c9f7016f29369 to your computer and use it in GitHub Desktop.
Save nickkuijpers/d3f5723c9f7016f29369 to your computer and use it in GitHub Desktop.
Wordpress PHP Get current product category
global $post;
$terms = get_the_terms( $post->ID, 'product_cat' );
foreach ($terms as $term){
$product_cat_id = $term->term_id;
$product_cat_name = $term->name;
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment