0

I am creating a child theme using WooCommerce Storefront. I am trying to use hooks as much as possible as I understand this is best practice.

However, even after I have removed all of the actions associated with this hook there is still a DIV remaining: <div class="col-full"></div>

I removed the actions by adding this into my themes functions.php file

function remove_default_hooks() {

    remove_action( 'storefront_header', 'storefront_site_branding',                    20 );
    remove_action( 'storefront_header', 'storefront_secondary_navigation',             30 );
    remove_action( 'storefront_header', 'storefront_primary_navigation_wrapper',       42 );
    remove_action( 'storefront_header', 'storefront_primary_navigation',               50 );
    remove_action( 'storefront_header', 'storefront_primary_navigation_wrapper_close', 68 );
    remove_action( 'storefront_header', 'storefront_product_search', 40 );
    remove_action( 'storefront_header', 'storefront_header_cart',    60 );
    remove_action( 'storefront_header', 'storefront_skip_links',                       0);
    remove_action( 'storefront_footer', 'storefront_handheld_footer_bar',           999 );

    }
    add_action( 'init', 'remove_default_hooks' );

If I remove the hook altogether the DIV disappears. I have searched through all the files both in the WooCommerce plugin and Storefront theme and can't find where this DIV is coming from. It's also not inside header.php

The DIV is located inside the <header>:

<header id="masthead" class="site-header fixed-top row no-gutters mt-0 pt-0 align-items-center" role="banner" style="">
<div class="col-full">
</div>
</header><!-- #masthead -->

This appears like so in header.php:

<header id="masthead" class="site-header fixed-top row no-gutters mt-0 pt-0 align-items-center" role="banner" style="<?php storefront_header_styles(); ?>">
<?php
/**
* Functions hooked into storefront_header action
*
* @hooked storefront_skip_links                       - 0
* @hooked storefront_social_icons                     - 10
* @hooked storefront_site_branding                    - 20
* @hooked storefront_secondary_navigation             - 30
* @hooked storefront_product_search                   - 40
* @hooked storefront_primary_navigation_wrapper       - 42
* @hooked storefront_primary_navigation               - 50
* @hooked storefront_header_cart                      - 60
* @hooked storefront_primary_navigation_wrapper_close - 68
*/
do_action( 'storefront_header' );    
?>
</header><!-- #masthead -->

I can't find an add_action for storefront_social_icons.

How do I remove this annoying DIV?

Edit: You can take a look here: Open Development Page

closed as off-topic by Jacob Peattie, Krzysiek Dróżdż, Howdy_McGee May 16 '18 at 0:41

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

4

Storefront version 3.0:

Code of the header.php in version 3.0

<header id="masthead" class="site-header" role="banner" style="<?php storefront_header_styles(); ?>">

    <?php
    /**
     * Functions hooked into storefront_header action
     *
     * @hooked storefront_header_container                 - 0
     * @hooked storefront_skip_links                       - 5
     * @hooked storefront_social_icons                     - 10
     * @hooked storefront_site_branding                    - 20
     * @hooked storefront_secondary_navigation             - 30
     * @hooked storefront_product_search                   - 40
     * @hooked storefront_header_container_close           - 41
     * @hooked storefront_primary_navigation_wrapper       - 42
     * @hooked storefront_primary_navigation               - 50
     * @hooked storefront_header_cart                      - 60
     * @hooked storefront_primary_navigation_wrapper_close - 68
     */
    do_action( 'storefront_header' ); ?>

</header><!-- #masthead -->

In version 3.0 the

<div class="col-full">

and

</div>

will be created by the hooks "storefront_header_container" and "storefront_header_container_close". You find the implementation of these two hooks in the file storefront-template-functions.php

To remove these hooks you can do something like this:

function remove_default_hooks() {

remove_action( 'storefront_header', 'storefront_header_container',                   0 );
remove_action( 'storefront_header', 'storefront_header_container_close',                   0 );

}

add_action( 'init', 'remove_default_hooks' );

Storefront version 2.8 and smaller:

Code of the header.php in version 2.8

<header id="masthead" class="site-header" role="banner" style="<?php storefront_header_styles(); ?>">
    <div class="col-full">

        <?php
        /**
         * Functions hooked into storefront_header action
         *
         * @hooked storefront_skip_links                       - 0
         * @hooked storefront_social_icons                     - 10
         * @hooked storefront_site_branding                    - 20
         * @hooked storefront_secondary_navigation             - 30
         * @hooked storefront_product_search                   - 40
         * @hooked storefront_primary_navigation_wrapper       - 42
         * @hooked storefront_primary_navigation               - 50
         * @hooked storefront_header_cart                      - 60
         * @hooked storefront_primary_navigation_wrapper_close - 68
         */
        do_action( 'storefront_header' ); ?>

    </div>
</header><!-- #masthead -->

In version 2.8 and smaller the

<div class="col-full">

and

</div>

are part of the header.php file. The only way to remove that two html elements is to overwrite header.php file in your child-template.

  • I think either my plugin or template was out of date and some of the actions you listed above did not show up. After updating everything I found the hooks you mentioned and everything went smoothly! Thank you! – joshkrz May 10 '18 at 21:57

Not the answer you're looking for? Browse other questions tagged or ask your own question.