WooCommerce store notice is hooked at wp_footer
. I remove it from wp_footer
and add it in the header.php
file after the immediate position of the opening body tag. But I observe that "store notice" is load after body content. Maybe it is loaded after the body DOM. And it is the reason for CLS issue.
functions.php
/* Move demo store notice to top. */
function custom_move_store_notice() {
if ( get_theme_mod( 'woocommerce_store_notice_top' ) ) {
remove_action( 'wp_footer', 'woocommerce_demo_store' );
add_action ( 'custom_after_body_open', 'woocommerce_demo_store', 1 );
}
}
add_action( 'wp_loaded', 'custom_move_store_notice' );
header.php
<body <?php body_class(); ?>>
<?php do_action( 'custom_after_body_open' ); ?>
I see the same problem in most WordPress E-Commerce websites that use "store notice" at the top side. My question is – Is it possible to load "store notice" along with body content?