Search code examples
phpfunctionwoocommercebanner

Woocommerce + oceanwp banner configuration in function.php


So my plan was to add custom banner to all pages simply using code in functions.php, it works, but not how I would like to

Code:


add_action( 'woocommerce_after_main_content', 'after_main_content', 1 );

function after_main_content() {
    echo  ' <style>
      .img-container {
        text-align: center;
      }
    </style>
 <div class="img-container">
<img src="https://www.prospecs.lt/wp-content/uploads/2020/12/dpdtt-1.png" >
  </div>
';
}

Problem: [1]: https://i.sstatic.net/5zBux.png

Only in pages with sidebars my banner get's allocated to another section. enter image description here Any ideas how to place it in the right place on pages with sidebar?

my site: www.prospecs.lt


Solution

  • I suggest, you should use a theme footer action. Which is: ocean_after_main So the code would be:

       add_action( 'ocean_after_main', 'after_main_content', 1 );
                    function after_main_content() {
                if( is_shop() ){
                        echo  ' <style>
                          .img-container {
                            text-align: center;
                          }
                        </style>
                     <div class="img-container">
                    <img src="https://www.prospecs.lt/wp-content/uploads/2020/12/dpdtt-1.png" >
                      </div>
                    ';
                }
        }