How to output php between header and woocommerce container

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

Topic custom-header woocommerce-offtopic Wordpress

Category Web


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.


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.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.