T
T
Temur Begiev2016-02-23 22:12:27
WordPress
Temur Begiev, 2016-02-23 22:12:27

What's with the archive-product.php file in woocommerce?

Copied the archive-product.php file to the theme/woo commerce/ folder in the theme. theme/wocommerce/archive-product.php
I needed to display a block with a message when displaying products of a certain category.
As I understand it, this file is responsible for displaying products when viewing a category.
Added code.
4029f217b0d641fb9c3c7e33897d06ee.PNG
But there were no changes.
Deleted the file and folder in the theme folder. Went directly to the plugin folder. Pasted there. Also zero response.
What's wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
max3wq, 2018-05-24
@max3wq

Most likely you have a self-written theme (instead of archive-product.php it pulls the page.php file), in order for archive-product.php to work, you need to insert the code in functions.php to declare support in the theme:

<?php
add_action( 'after_setup_theme', 'woocommerce_support' );
function woocommerce_support() {
    add_theme_support( 'woocommerce' );
} ?>

Then create a woocommerce.php file in the theme root for your template, with content for example:
<?php
/**
 * Шаблон обычной страницы (page.php)
 * @package WordPress
 */
get_header(); // подключаем header.php ?>
<section>
  <div class="container">
    <div class="row">
    <?php get_sidebar(); // подключаем sidebar.php ?>
      <div class="<?php content_class_by_sidebar(); // функция подставит класс в зависимости от того есть ли сайдбар, лежит в functions.php ?>">
        <?php woocommerce_breadcrumb(); ?>
        <?php woocommerce_content(); ?>
      </div>

    </div>
  </div>
</section>
<?php get_footer(); // подключаем footer.php ?>

Then, in the folder with the theme, the woocommerce folder, drop archive-product.php into it and all your changes will already be accepted in it.

M
Mr Crabbz, 2016-02-24
@Punkie

theme/woocommerce/archive-product.php -> theme/woocommerce/archive-product.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question