Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WooCommerce how to check if page is_shop() in functions.php?

In WooCommerce, My Category Listing page and product listing page are rendered from archieve-product.php ( By Default) . How to check if page is_shop() in functions.php? As is_shop function does not work in functions.php. I simply want to remove my sidebar from Category listing page not from product listing page.

like image 526
kd patel Avatar asked May 20 '16 15:05

kd patel


People also ask

How does WooCommerce check single product page?

WooCommerce Check If Product Page If you are looking for a way to check if you are on a product page in WooCommerce, you most likely think you should use WordPress single post conditional tag something like is_single( ).

How do I get a shop page title in WordPress?

3.1 Using the WordPress Settings To do so, navigate to Pages > All Pages from your WordPress dashboard. Find the 'Shop – Shop Page' and click the Edit button. You can then change your shop page title as shown below. Once done, click on the Update button to save your changes.


1 Answers

When placed inside a hook, is_shop will work in functions.php

add_action( 'template_redirect', 'custom_template_redirect' );

function custom_template_redirect() {

    if( is_shop() ) :

         // code logic here

    endif;    
}

Here is a list of all WooCommerce conditionals

like image 110
Anand Shah Avatar answered Oct 14 '22 03:10

Anand Shah