- This topic has 7 replies, 2 voices, and was last updated 4 years, 2 months ago by David.
-
AuthorPosts
-
January 29, 2020 at 7:14 am #1148283Paul
Hi,
want to add a little bit of code that goes in front of the /<head> tag in the footer. I already have some text in the footer bar and would like this to appear above it. It’s a GDPR notice and will disappear when user clicks OK.Is it best to put it into the footer window or as a widget in the footer?
Read some posts/info and created and activated the plug-in. But it doesn’t appear in the front page.
Have I missed something? Thanks, here’s the code:
<?php if ( is_front_page() ) : ?>
/*
Plugin Name: WAC GDPR plug
Plugin URI:
Description:
Version: 2020.1
Author:
Author URI:
License:
License URI:
*/
<link rel=”stylesheet” type=”text/css” href=”//wpcc.io/lib/1.0.2/cookieconsent.min.css”/><script src=”//wpcc.io/lib/1.0.2/cookieconsent.min.js”></script>
<script>window.addEventListener(“load”, function(){window.wpcc.init({“border”:”thin”,”corners”:”small”,”colors”:{“popup”:{“background”:”#edeff5″,”text”:”#838391″,”border”:”#edeff5″},”button”:{“background”:”#0073ff”,”text”:”#ffffff”}},”content”:{“message”:”This website uses cookies (including 3rd party: Google analytics + Facebook links) to help improve website function and user experience. Our Privacy Policy explains how and why.”,”href”:”https://www.warlinghamarchers.uk/cookie-policy”,”link”:”See the Privacy Policy”}
})});
</script>
<?php endif; ?>January 29, 2020 at 8:35 am #1148367DavidStaffCustomer SupportHi there,
you can use the Hook Element to add the script:
https://docs.generatepress.com/article/hooks-element-overview/
The
WP_footer
hook is in the footer.January 30, 2020 at 3:47 am #1149114PaulThanks David,
read all that, added element with the code BUT where do I put the code listed under Hooks/Usage herePS do I need to create a child theme to preserve these elements?
Paul
January 30, 2020 at 5:17 am #1149181DavidStaffCustomer SupportNo child theme required if using the Hook Element.
Simply:
Appearance > Elements > New –> Hook.
Add your code to the content text area.
Select theWP_Head
hook and check Execute PHP.
Then on the Display Rules tab – set the Location where you want the script to fire e.gEntire Site
January 30, 2020 at 5:39 am #1149196PaulThanks David,
checked live site and it worked – sort of. I used the hook ‘generate before footer’ and thought it might stick above the footer if I scrolled up/down the page – instead it moves up/down screen with me.
I’m not too bothered by that but just wondered, for future reference, is there a hook that would stick it to the footer.
PaulJanuary 30, 2020 at 6:20 am #1149222DavidStaffCustomer SupportIn this instance the hook you choose has no baring on the position of the cookie notice.
What the hook is doing is simply adding some code that gets executed by the browser. It is the code that is responsible for how and where the cookie notice is displayed.I am not sure where the code comes from – but maybe the offer some other ‘styling’ options.
January 30, 2020 at 8:42 am #1149516PaulThat’s fine. Thanks David
January 30, 2020 at 3:58 pm #1149840DavidStaffCustomer SupportYou’re welcome
-
AuthorPosts
- You must be logged in to reply to this topic.