Custom HTML and CSS not rendering correctly when adding PHP snippet to wp_footer in WordPress [closed]

1 week ago 15
ARTICLE AD BOX

I am trying to add a custom promotional banner to my WordPress site. My goal is to output this HTML and CSS using a PHP function hooked to wp_footer so it appears consistently across all pages.

Here is the code I constructed:

function custom_promo_banner() { // I closed the PHP tag here to write raw HTML ?> <!-- Inline CSS specifically for this banner --> <style> .promo-box { background-color: #f0f0f0; padding: 20px; text-align: center; border: 1px solid #ccc; border-radius: 5px; } </style> <!-- The HTML structure for the banner box --> <div class="promo-box"> <p>This is a custom promo box.</p> </div> <?php // Reopening PHP tag } // Hooking the function to wp_footer so it loads at the bottom of the page add_action('wp_footer', 'custom_promo_banner');
Read Entire Article