Shortcode in footer.php solution
-
Hi everyone. I thought I’d share this solution to allow you to insert the button to withdraw consent directly in the footer and make it appear elegantly on the left at the bottom.
First, for the shortcode to work, you need to put this code in function.php
add_filter('widget_text', 'shortcode_unautop'); add_filter('widget_text', 'do_shortcode');
Then in the footer.php file, obviously of the child theme, you need to insert this before the
<?php wp_footer(); ?>
tag<div> <?php echo do_shortcode('[revoke_cookie_consent]') ?> </div> <style> .cookie-notice-consent__revoke-button { background-color:#212121; background-image:none; color:#fff; text-shadow:none; font-weight:bold; transition:.2s; position:fixed; padding:5px 15px; bottom:0; height:auto; width:auto; left:5%; z-index:99999999; box-shadow:0 0 10px #000; border:none; border-radius:0; font-size:12px; line-height:initial; margin:0!important; } .cookie-notice-consent__revoke-button:hover { background-color:#545454; text-shadow:0 0 1px #000; color:#fff!important; margin:0!important; } .cookie-notice-consent__revoke-button:active { background-color:#212121; background-image:none; color:#fff; text-shadow:none; font-weight:bold; transition:.2s; position:fixed; padding:5px 15px; bottom:0; height:auto; width:auto; left:5%; z-index:99999999; box-shadow:0 0 10px #000; border:none; border-radius:0; font-size:12px; line-height:initial; } </style>
This way we also give a touch of style to our button. Let me know if it works !!!
- The topic ‘Shortcode in footer.php solution’ is closed to new replies.