Answers for "get product category wordpress php"

PHP
0

wc php get product category in product page

global $post;
$terms = get_the_terms( $post->ID, 'product_cat' );
foreach ($terms as $term) {
    $product_cat_id = $term->term_id;
    break;
}
Posted by: Guest on January-06-2022
0

wordpress get product category name by termid

// Testing that $_GET['product-cato'] has been requested and that the product category exists.
if( isset( $_GET['product-cato'] ) && term_exists( intval($_GET['product-cato']), 'product_cat' ) ){
    // Get the corresponding WP_Term object
    $term = get_term( intval($_GET['product-cato']), 'product_cat' );
    //Display the term name for the product category
    echo '<p>' . $term->name . '</p>';
}
Posted by: Guest on August-23-2021

Code answers related to "get product category wordpress php"

Browse Popular Code Answers by Language