Tuesday, July 26, 2022
HomeWordPress Developmentwoocommerce offtopic - is_product_category() present false on product class web page

woocommerce offtopic – is_product_category() present false on product class web page


I’ve an archive product web page with this hyperlink web site.com/product-category/company-establishment-and-management/

when i attempt to use is_product_category() it present me false
what I make unsuitable?
attempt to change woocommerce archive web page title

if (apply_filters('woocommerce_show_page_title', true)) {//TODO for optimization transfer 1 
    var_dump(is_product_category());//Present false
        if (is_product_category()) { 

            $product_parent_categories_all_hierachy = get_ancestors( $post->id, 'product_cat' );  
            // This cuts the array and extracts the final set within the array
            $last_parent_cat = array_slice($product_parent_categories_all_hierachy, -1, 1, true);
            foreach ($last_parent_cat as $last_parent_cat_value) {
                // $last_parent_cat_value is the id of probably the most prime stage class, may be use whichever one like
                echo '<sturdy>' . $last_parent_cat_value . '</sturdy>';
            }
                    
            echo '<h1 class="woocommerce-products-header__title page-title">'. $last_parent_cat_value.'</h1>';
        } 
}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments