Tagged: enfold
Hi,
I have the need to enter a code (scripts privacy legislation) before the tag </head> of all pages.
At the time I put this code in header.php
It works very well, but I want to avoid changing the theme Enfold, I would put this code in the file functions.php of the my child theme.
You can help me?
Thanks
Hi macrunner!
You can use this in functions.php to hook to wp_head:
function add_custom_code(){
//YOUR CODE HERE
}
add_action('wp_head', 'add_custom_code');
Cheers!
Rikard
Hi Rikard,
unfortunately it does not work, I get a blank page.
Maybe because my code is complex?
Here is the code that I use:
<link rel="stylesheet" type="text/css" href="http://www.mydomain.com/privacy/main.css"/>
<script type="text/javascript" src="http://www.mydomain.com/privacy/cookieplugin.js"></script>
<script type="text/javascript">
// <![CDATA[
cc.initialise({
cookies: {
social: {},
necessary: {}
},
settings: {
bannerPosition: "push",
disableallsites: true
},
strings: {
socialDefaultDescription: 'Facebook, Twitter and other social websites need to know who you are to work properly.',
necessaryDefaultTitle: 'Necessary',
privacySettings: 'Privacy settings',
savePreference: 'Save settings',
allowCookiesImplicit: 'Close',
backToSiteSettings: 'Back Settings'
}
});
// ]]>
Thanks!
Hey!
Please change the code to following one
function add_custom_code(){
?>
//YOUR CODE HERE
<?php
}
add_action('wp_head', 'add_custom_code');
Best regards,
Yigit
Hi Ygit,
It works great
thank you