ERROR: Header Increased By 875px When Adding A Cookie Notice In Header.Php !
-
Hello, this is what I added in header.php to display a cookie notice
window.cookieconsent_options = {“message”:”Ce site utilise des cookies pour vous garantir la meilleure expérience.”,”dismiss”:”OK”,”learnMore”:”En savoir plus”,”link”:”https://osezrealiservosreves.com/mentions-legales/”,”theme”:”dark-bottom”};
I have the unpleasant surprise to see that the header grew in size for no reason, basically by 875px
What is the origine of this issue?
Thank you for letting me know
Pascal
The page I need help with: [log in to see the link]
-
Did you take it out? Page looks fine to me, but I didn’t see any cookie notice.
Did you add that code inside a
<script></script>tag?Also,
window.cookieconsent_optionsisn’t a standard property ofwindow? Is there also a script or plugin somewhere that acts on these options?OK so it’s weird because the bug doesn’t display when I am in private navigation, but it does in regular navigation.
The cookie notice appears in the footer area.Maybe it got disabled because I tried to customize the header.php from my child theme, and went back to default for the header.php of my parent theme.
So this is the beginning of my file header.php in my child theme with the integration I made, if you want to have a look:
<?php
$options = thrive_get_options_for_post();
$enable_fb_comments = thrive_get_theme_options( “enable_fb_comments” );
$fb_app_id = thrive_get_theme_options( “fb_app_id” );
$logo_pos_class = ( $options[‘logo_position’] != “top” ) ? “side_logo” : “center_logo”;
$float_menu_attr = “”;
if ( $options[‘navigation_type’] == “float” || $options[‘navigation_type’] == “scroll” ) {
$float_menu_attr = ( $options[‘navigation_type’] == “float” ) ? ” data-float=’float-fixed'” : ” data-float=’float-scroll'”;
}
?><!DOCTYPE html>
<?php tha_html_before(); ?>
<html <?php language_attributes() ?>>
<head><!– Begin Cookie Consent plugin by Silktide – http://silktide.com/cookieconsent –>
<script type=”text/javascript”>
window.cookieconsent_options = {“message”:”Ce site utilise des cookies pour vous garantir la meilleure expérience.”,”dismiss”:”OK”,”learnMore”:”En savoir plus”,”link”:”https://osezrealiservosreves.com/mentions-legales/”,”theme”:”dark-bottom”};
</script><script type=”text/javascript” src=”//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/1.0.10/cookieconsent.min.js”></script>
<!– End Cookie Consent plugin –><?php tha_head_top(); ?>
<title>
<?php wp_title( ” ); ?>I can see the bug of the header on mobile version, and the cookie notice displays correctly as well.
I still can’t see anything. Are you using a caching plugin of some kind? If so I (and you in private browsing) are likely seeing the cached version before you made the change. Or does the script let you only display it for users in the EU (where I am not)?
Well I use WP Fatest Cache and Cloudflare
I have deleted the cache.
Disabling them did’nt change anything, I still see the issue on my side
But there might be an issue with this, yes.No scripts for just EU
I can see the cookie message now that the cache is cleared, but I can’t see anything unusual about the size of the header, and it’s certainly nowhere near 875px. Could you share a screenshot?
Looks like the bug is not there on mobile version anymore
But I can see it on Google Chrome and opera
Nevermind, it’s on mobile as well
Your screenshot shows a blank white rectangle with red border, is that really what you see?
FWIW, the cookie notice appears fine to me on Chrome for both mobile and desktop. It’s a full width overlay along the bottom of the screen, so it takes on what ever the window width is. As much as we would like to help, it’s very difficult to resolve issues that we cannot replicate.
Maybe try disabling all of your browser extensions and see if that changes how things look on your end?
I do not have a red border, this is what I made with Paint to show the area
Yes for the cookie notice
It is displayed on the footer
Yes but still an issue with the header.I have tried another cookie notice bar with different code
I can see that sometimes the bug resolves itself, and then comes again.First, it looks like that if I put this setting in header.php of my child theme, it is not taken into account.
It has to be header.php, which is weird.Also, I’m a bit unfamiliar with child themes, but does the header.php of the child theme has to be a replicate of the parent theme?
Or can I just add what I want (in this case, the cookie notice) in the child theme, between <head> and </head> lines, and then have the header.php in the parent theme with the rest of its content?
Let me know thanks
Or can I just add what I want (in this case, the cookie notice) in the child theme, between <head> and </head> lines, and then have the header.php in the parent theme with the rest of its content?
No, if your child theme has its own
header.phpfile then it will replace the parent theme’s. So if something from your parent theme’s header.php file isn’t inside your child theme’s, it won’t appear.Okay thank you for the precision
Still, it seems the code won’t work if it’s inserted in the child theme and not in the parent theme, which is weird.
I have created the child theme with a copy-paste from the parent theme, and then I have added the code of the cookie notice.
I confirm the header.php from child theme won’t display the cookie notice despite the bug.
I’m defintely still having the issue of the big header, I’m surprised you can’t see it now
Might be a silly question, but have you actually activated the child theme?
The topic ‘ERROR: Header Increased By 875px When Adding A Cookie Notice In Header.Php !’ is closed to new replies.
