[Support request] Woocommerce: Calling different custom archive product template for searches

Home Forums Support [Support request] Woocommerce: Calling different custom archive product template for searches

Home Forums Support Woocommerce: Calling different custom archive product template for searches

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #628602
    Max

    I am using the following snippet in my functions.php file to call a custom template for my Woo shop page. It is working fine.

    add_filter( 'template_include', 'custom_shop_page_template_include', 50, 1 );
    function custom_shop_page_template_include( $template ) {
        if( is_shop() ) {
            $template = get_stylesheet_directory() . '/woocommerce/archive-product-custom-shop-page.php';
        } 
        return $template;
    }

    However, this template also gets called for a search with “no products displayed”.

    How can I modify the above snippet so that the results from a search are displayed in a different template:

    If shop = product-archive-custom-shop-page.php
    If search = product-archive-custom-search-page.php
    #628767
    Leo
    Staff
    Customer Support

    Hi Max,

    This sounds like more a question for WooCommerce’ support.

    Have you checked with them?

    They should be more familiar with how their template tags work.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.