Support » Plugin: WooCommerce » How to insert a div only in the Homepage

  • Hey Guys,

    On this page http://www.trauringe-am-rhein.de I would like to insert a hero div just into the homepage.

    At the moment I have done it with this action:

    add_action( ‘storefront_before_content’, ‘jk_storefront_header_content’, 40 );

    However this insert it on every page, any ideas how to get this just to the front page?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi Lukasz,
    You can build a function to display it like:

    function jk_storefront_header_content(){
    if(is_home() || is_front_page()) {
    echo 'display hero div or do_shortcode below';
    }
    };
    add_action( 'storefront_before_content', 'jk_storefront_header_content', 40 );
    

    I hope that will help.
    M

    Hi Mariusz,

    thanks so much for your help!

    This looks exactly like the thing I was looking for, however I dont
    understand where to put the content I want to insert in.

    Your function looks like this now:

    function jk_storefront_header_content(){
    if(is_home() || is_front_page()) {
    echo ‘display hero div or do_shortcode below’;

    <section id=”hero”>
    <div class=”wrapper_hero”>

    <h3>von Verlobungsringen bis zu Uhren</h3>
    <h2>Ihr Schmuckshop in Biingen</h2>
    /img/dedeee.svg” alt=”linie” width=”300px”>

    </div>
    </section>

    }
    };
    add_action( ‘storefront_before_content’, ‘jk_storefront_header_content’, 40 );

    but this isnt right, isnt it?

    Plugin Support RK

    (@riaanknoetze)

    This forum is for supporting of the core WooCommerce plugin only. For Storefront, please use https://wordpress.org/support/theme/storefront

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.