E
E
Ex1st2021-01-31 00:38:08
WordPress
Ex1st, 2021-01-31 00:38:08

Why post layout interferes with woocommerce layout?

When I pull the layout for the detailed product page, for some reason, the woocommerce layout is added inside the containers from the usual single post.
I throw divs on VP hooks like this:

<?php
add_action('woocommerce_before_single_product_summary', 'coffe_start_wrapper_product', 5);
function coffe_start_wrapper_product()
{
    ?>
    <section class="banner-bottom-wthreelayouts py-lg-5 py-3">
    <div class="container">
    <div class="inner-sec-shop pt-lg-4 pt-3">
    <div class="row">
    <?php
}

add_action('woocommerce_after_single_product_summary', 'coffe_after_single_product_img_start', 25);
function coffe_after_single_product_img_start()
{
    ?>
    </div>
    </div>
    </div>
    </section>
    <?php
}

add_action('woocommerce_before_single_product_summary', 'coffe_before_single_product_summary_start', 5);
function coffe_before_single_product_summary_start()
{
    ?>
    <div class="col-lg-4 single-right-left ">
    <div class="grid images_3_of_2">
    <?php
}

add_action('woocommerce_before_single_product_summary', 'coffe_after_single_product_end', 70);
function coffe_after_single_product_end()
{
    ?>
    </div>
    </div>
    <?php
}

add_action('woocommerce_single_product_summary', 'test', 0);
function test()
{
    ?>
    <div class="col-lg-8 single-right-left simpleCart_shelfItem">
    <?php
}

add_action('woocommerce_single_product_summary', 'coffe_after_single_product_entry_end', 70);
function coffe_after_single_product_entry_end()
{
    ?>
    </div>
    <?php
}

And the title, instead of being inside entry_summary, is displayed in another block, indicated by header:
6015d00e85771970546257.png
6015d0e343dd0580806829.png
But his hook colleagues got into entry_summary. And the title did not even get into the wrapper, although it is after the location of the hook and priority.

And I think I found the culprit. content.php contains the following code:
<header class="entry-header">
    <?php
    if ( is_singular() ) :
      the_title( '<h1 class="entry-title">', '</h1>' );
    else :
      the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
    endif;

There he is. A header with a title, it is he who is pulled into the layout of goods. But shouldn't Woocommerce products have their own, separate post template?

P.S. I pull on an empty topic from the generator.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Ex1st, 2021-02-02
@Ex1st

The problem was that in functions.php you need to declare that the theme supports WooCommerce. The code is like this:

add_action('after_setup_theme', 'mytheme_add_woocommerce_support');
function mytheme_add_woocommerce_support() {
    add_theme_support('woocommerce');
}

V
Vova, 2021-02-02
@vova87

You need to create a woocommerce folder in the theme and place the single-product.php file from woocommerce in this folder, then this template will be pulled for the products.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question