I'm trying to use is_category in woocommerce.php
which is not working. I want to print the title according the page.
IF a page is category page then will print woocommerce_page_title()
and if a page is product then should print the_title()
.
And the code I am using in woocommerce.php
is:
<?php if(is_category()){ ?>
<h1 class="page-title"><?php woocommerce_page_title(); ?></h1>
<?php }
else{
the_title();
}
?>
But in every case it is printing the_title()
. I think is_category()
is not working for woocommerce.
Or Can any one tell how woocommerce do it to print category and product title?
Any help will be appreciated.
What is a WooCommerce Category Page? WooCommerce allows users to list products from a specific category or subcategory in a grid-style layout. By default, large product images with their name, price, and purchase options will be displayed.
I have found the way to do it by checking if $cat_id is available or not on that page by the following. $cat_id = get_query_var('cat'); Now we can check if $cat_id is available then it is a category page otherwise it is not.
Show the WooCommerce category descriptionCopy the template file from wp-content/plugins/woocommerce/templates/archive-product. php to wp-content/themes/[your-child-theme]/woocommerce/archive-product. php. Now we can edit that without changing any plugin files directly (which could get replaced on the next update).
you should use
is_product_category()
instead of
is_category()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With