Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save JeroenSormani/8bc04b14fc058c0a62269c6438c4da8e to your computer and use it in GitHub Desktop.
Save JeroenSormani/8bc04b14fc058c0a62269c6438c4da8e to your computer and use it in GitHub Desktop.
A scheduled site-wide banner in WooCommerce / WordPress
<?php // For implementation instructions see: https://aceplugins.com/how-to-add-a-code-snippet/
/**
* Basic site-wide banner.
*/
function ace_custom_site_banner() {
$from_time = new DateTime( '2019-04-21 00:00' );
$to_time = new DateTime( '2019-04-22 23:59' );
if ( new DateTime() > $from_time && new DateTime() < $to_time ) {
?><div class="site-banner">
<span>
<strong style="">Sale!</strong> Get up to 50% off, sale ending this friday.
</span>
</div><?php
}
}
add_action( 'wp_footer', 'ace_custom_site_banner' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment