admin管理员组

文章数量:1122846

I am customizing my product detail page. I put the code before the single product summary in content-single-product.php

As you can see here: Link to product page

But i want it like this:

Can some one tell me where i have to put the code to place it outside the woocommerce container?

Thanks,

Chiel

I am customizing my product detail page. I put the code before the single product summary in content-single-product.php

As you can see here: Link to product page

But i want it like this:

Can some one tell me where i have to put the code to place it outside the woocommerce container?

Thanks,

Chiel

Share Improve this question asked May 7, 2019 at 12:11 Chiel van der ZeeChiel van der Zee 111 bronze badge
Add a comment  | 

2 Answers 2

Reset to default 0

You can try adding php in index.php file in your theme folder after get_header() is called.Your php block will come after header and before woo commerce content.

The function responsible for opening WooCommerce content wrapper is attached to woocommerce_before_main_content action hook with priority 10.

You can wrap your code into function and attach it to that hook with priority less than 10.

add_action( 'woocommerce_before_main_content', 'se337291_before_content_wrapper');
function se337291_before_content_wrapper()
{
   // display something only on single product page
   if ( ! is_product() ) 
      return;
   //
   // your code here...
   //
}

Another option is to copy the single-product.php file to the theme directory and modify it. Here you will find information on how to overwrite templates.

本文标签: How to output php between header and woocommerce container