Skip to content

Instantly share code, notes, and snippets.

@marklchaves
Created November 29, 2021 02:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save marklchaves/3718e333ccc577ca175a9d4840ade9f6 to your computer and use it in GitHub Desktop.
Save marklchaves/3718e333ccc577ca175a9d4840ade9f6 to your computer and use it in GitHub Desktop.
Example using wp_body_open hook to add a top banner
<?php // Ignore this first line when copying to your child theme's functions.php file.
add_action('wp_body_open', function() { ?>
<style>
.top-banner {
background-color: firebrick;
color: white;
display: grid;
font-size: 2rem;
height: 10vmin;
place-items: center;
width: 100vw;
}
</style>
<div class="top-banner">This is my cool Top Banner!</div>
<?php } );
/**
* You can add the PHP code snippet to your child theme's functions.php file
* or with third-party plugins such as My Custom Functions and Code Snippets.
* /
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment