skip to Main Content

I am using the Elementor Plugin in WordPress.

I am using a child theme.
In function.php file I have added theme support for woocommerce using add_themesupport('woocommerce') and create folder name is woocommerce.

I have downloaded archive-product.php file from woocommerce plugin and paste in the theme_name/woocommerce.

I am using Elementor plugin for creating pages.

I want to create a custom design and it is not possible in the elementor.

so I have to override archive-product.php file but it is not working.
When I deactivate Elementor, my template override page is working.

can you please help how can I customize archive-product.php file with elementor?

Thank you in advance.

2

Answers


  1. It may be an issue related to this (from the Woocommerce documentation):

    If your theme has a woocommerce.php file, you will be unable to override the woocommerce/archive-product.php custom template in your theme, as woocommerce.php has priority over other template files. This is intended to prevent display issues.

    You can check the complete template documentation here: https://docs.woocommerce.com/document/template-structure/

    Login or Signup to reply.
  2. What helped me was this piece of code (add it to your functions.php):

    add_filter( 'template_include', 'woocommerce_custom_archive_template', 99 );
    function woocommerce_custom_archive_template( $template ) {
      if ( is_post_type_archive( 'product' ) ) {
        $new_template = locate_template( array( 'archive-product.php' ) );
        if ( '' != $new_template ) {
          return $new_template ;
        }
      }
      return $template;
    }
    

    This function is used to customize the WooCommerce product post type archive page template. It checks if the archive is for the product post type, and if it is, it looks for a custom archive-product.php template file in the theme folder. If the file exists, it loads the custom template instead of the default WooCommerce template. This function is necessary if you want to customize the product archive page template in your theme.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search