Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bencicpatricija/3eec5e8345202c7b06d4838219dff112 to your computer and use it in GitHub Desktop.
Save bencicpatricija/3eec5e8345202c7b06d4838219dff112 to your computer and use it in GitHub Desktop.
Get "Uncategoriezed" term ID from "product_cat" taxonomy
/**
* Get "Uncategorized" term ID from "product_cat" taxonomy.
*/
function pb_get_product_uncategorized_term_id() {
$uncategorized_term_id = get_term_by( 'slug', 'uncategorized', 'product_cat')->term_id;
if ( ! class_exists( 'woocommerce' ) || ! $uncategorized_term_id ) {
return false;
} else {
return $uncategorized_term_id;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment