How to check if a page is category or product in woocommerce?

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.

Answers


you should use

is_product_category()

instead of

is_category()

Try creating a archive-product.php file within the theme templates.

I usually copy the one that is in the woocommerce folder and add a span with "test" text to the one I create so I can see it's working.


Need Your Help

Target iPhone Simulator Macro Not Working

iphone cocoa-touch

Using the TARGET_IPHONE_SIMULATOR macro results in the same constant values being defined in am application. For example: