• Resolved guardiano78

    (@guardiano78)


    Hello everyone,
    I need to hide the detail page for products belonging to specific categories.
    The redirect to the shop page would also be fine.
    I found this code … the following code is interesting because when I click to access the detail page of a product, the snippet redirects to the shop page.

    add_action('template_redirect','custom_shop_page_redirect');
    function custom_shop_page_redirect(){
        if (class_exists('WooCommerce')){
            if(is_product()){
                wp_redirect(home_url('/shop/'));
                exit();
            }
        } 
        return;
    } 

    this code affects all products.
    I would like to be able to decide which products to prevent access to the detail page.
    Do you think it can be done?

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘exclude products that belong to specific categories’ is closed to new replies.