wordpress: adding a tag makes the tag autoclose
Good day all.
I'm using a "amp" generator on a wordpress site, one of the actions of this plugin is to add a biolerplate tag just before the </head>
and a <noscript>
tag with a fallback.
Google search console keep warning me about a specific error:
"The mandatory tag 'noscript enclosure for boilerplate' is missing or incorrect."
So I start to investigate.
What I've found is that "something" is injecting the </head><body>
just before the <noscript>
opening tag, if I change the place where I put the noscript tag, the other two are moved too.
this is the code rendered:
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style>
</head><body><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
I have done a lot of tests and seems that the <noscript>
tag is the point of this error.
I've read also some other answers that are saying that the document should not be strict xhtml 1.1, which is not the case, infact these are the first things rendered on the page:
<!DOCTYPE html>
<html amp lang="it-IT"><head><meta charset="utf-8"><link rel="dns-prefetch" href="https://cdn.ampproject.org">
I'm trying to figure out what I can do to solve this error that is present across many sites, with different plugins and themes (and also wordpress versions).
UPDATE:
I've tried to add manually a <noscript>
tag in the code, and everytime I add it in the <head>
section, the section get closed, and the <body>
section is opened, without any class (so it's seems like a bug).
if you like to see the bug, just go here and look for the code:
https://www.assistenzamalasanita.com/2015/07/errori-medici-durante-il-parto-come-si-valutano/amp/
UPDATE 2
Disabling ALL plugins and switching to default theme has no effect on this.
Also, I have copied the entire site as is on another server, in which the problem is not present, the WP sites are identical, and also the serer configurations should be, BUT on the site that is working I can see that the HTTP request has an attribute about the php version (7.0.2) which the other site doesn't have.
is that possible that this can influence the rendering of the page??
to see the site that works:
https://www.doors.it/iride/2017/10/risarcimento-malasanita/amp
UPDATE 3
this is the part of the plugin that is actually write the code of the boilerplate (which has the head and body mistaken tags).
add_action( 'amp_post_template_head', 'amp_post_template_add_boilerplate_css' );
function amp_post_template_add_boilerplate_css( $amp_template ) {
?>
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
<?php
}
As you may notice, the entire block is inserted in one shot, there is no logic behind it and the page should be rendered as is (in that code, I've tried to change the tags into <nonscript>
and everything was fine, the head tags isn't been closed and the body tag is opened in the right place, with the right classes.
html wordpress amp-html noscript accelerated-mobile-page
|
show 16 more comments
Good day all.
I'm using a "amp" generator on a wordpress site, one of the actions of this plugin is to add a biolerplate tag just before the </head>
and a <noscript>
tag with a fallback.
Google search console keep warning me about a specific error:
"The mandatory tag 'noscript enclosure for boilerplate' is missing or incorrect."
So I start to investigate.
What I've found is that "something" is injecting the </head><body>
just before the <noscript>
opening tag, if I change the place where I put the noscript tag, the other two are moved too.
this is the code rendered:
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style>
</head><body><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
I have done a lot of tests and seems that the <noscript>
tag is the point of this error.
I've read also some other answers that are saying that the document should not be strict xhtml 1.1, which is not the case, infact these are the first things rendered on the page:
<!DOCTYPE html>
<html amp lang="it-IT"><head><meta charset="utf-8"><link rel="dns-prefetch" href="https://cdn.ampproject.org">
I'm trying to figure out what I can do to solve this error that is present across many sites, with different plugins and themes (and also wordpress versions).
UPDATE:
I've tried to add manually a <noscript>
tag in the code, and everytime I add it in the <head>
section, the section get closed, and the <body>
section is opened, without any class (so it's seems like a bug).
if you like to see the bug, just go here and look for the code:
https://www.assistenzamalasanita.com/2015/07/errori-medici-durante-il-parto-come-si-valutano/amp/
UPDATE 2
Disabling ALL plugins and switching to default theme has no effect on this.
Also, I have copied the entire site as is on another server, in which the problem is not present, the WP sites are identical, and also the serer configurations should be, BUT on the site that is working I can see that the HTTP request has an attribute about the php version (7.0.2) which the other site doesn't have.
is that possible that this can influence the rendering of the page??
to see the site that works:
https://www.doors.it/iride/2017/10/risarcimento-malasanita/amp
UPDATE 3
this is the part of the plugin that is actually write the code of the boilerplate (which has the head and body mistaken tags).
add_action( 'amp_post_template_head', 'amp_post_template_add_boilerplate_css' );
function amp_post_template_add_boilerplate_css( $amp_template ) {
?>
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
<?php
}
As you may notice, the entire block is inserted in one shot, there is no logic behind it and the page should be rendered as is (in that code, I've tried to change the tags into <nonscript>
and everything was fine, the head tags isn't been closed and the body tag is opened in the right place, with the right classes.
html wordpress amp-html noscript accelerated-mobile-page
1
Can you let me know the plugin you are using for AMP?
– Outsource WordPress
Sep 15 '18 at 6:18
AMP for WP - Accelerated Mobile Pages for WordPress
– Matteo Bononi 'peorthyr'
Sep 18 '18 at 8:50
1
You need to provide a Minimal, Complete, and Verifiable example. There is no way for us to tell why the HTML is being inserted in the wrong place without seeing the PHP that is inserting it.
– Quentin
Sep 18 '18 at 10:56
1
The callback/hookamp_post_template_add_boilerplate_css
may have been moved/relocated fromamp_post_template_head
toamp_start
orampforwp_body_beginning
- the latter two would add thenoscript
tag in thebody
and not thehead
. To confirm, try adding this code infunctions.php
:add_action( 'ampforwp_body_beginning', function(){ var_dump( $GLOBALS['wp_filter'] ); } );
and then share/inspect thevar_dump()
output.
– Sally CJ
Sep 18 '18 at 13:43
1
Alright @MatteoBononi'peorthyr', but you can also try this: remove the action -remove_action( 'amp_post_template_head', 'amp_post_template_add_boilerplate_css' )
and copy the entire HTML fromamp_post_template_add_boilerplate_css()
and add it via the settings page/UI - the AMP plugin uses output buffering (so even with manual HTML addition via the UI, thenoscript
might still be pushed into thebody
), but you can try..
– Sally CJ
Sep 19 '18 at 14:53
|
show 16 more comments
Good day all.
I'm using a "amp" generator on a wordpress site, one of the actions of this plugin is to add a biolerplate tag just before the </head>
and a <noscript>
tag with a fallback.
Google search console keep warning me about a specific error:
"The mandatory tag 'noscript enclosure for boilerplate' is missing or incorrect."
So I start to investigate.
What I've found is that "something" is injecting the </head><body>
just before the <noscript>
opening tag, if I change the place where I put the noscript tag, the other two are moved too.
this is the code rendered:
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style>
</head><body><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
I have done a lot of tests and seems that the <noscript>
tag is the point of this error.
I've read also some other answers that are saying that the document should not be strict xhtml 1.1, which is not the case, infact these are the first things rendered on the page:
<!DOCTYPE html>
<html amp lang="it-IT"><head><meta charset="utf-8"><link rel="dns-prefetch" href="https://cdn.ampproject.org">
I'm trying to figure out what I can do to solve this error that is present across many sites, with different plugins and themes (and also wordpress versions).
UPDATE:
I've tried to add manually a <noscript>
tag in the code, and everytime I add it in the <head>
section, the section get closed, and the <body>
section is opened, without any class (so it's seems like a bug).
if you like to see the bug, just go here and look for the code:
https://www.assistenzamalasanita.com/2015/07/errori-medici-durante-il-parto-come-si-valutano/amp/
UPDATE 2
Disabling ALL plugins and switching to default theme has no effect on this.
Also, I have copied the entire site as is on another server, in which the problem is not present, the WP sites are identical, and also the serer configurations should be, BUT on the site that is working I can see that the HTTP request has an attribute about the php version (7.0.2) which the other site doesn't have.
is that possible that this can influence the rendering of the page??
to see the site that works:
https://www.doors.it/iride/2017/10/risarcimento-malasanita/amp
UPDATE 3
this is the part of the plugin that is actually write the code of the boilerplate (which has the head and body mistaken tags).
add_action( 'amp_post_template_head', 'amp_post_template_add_boilerplate_css' );
function amp_post_template_add_boilerplate_css( $amp_template ) {
?>
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
<?php
}
As you may notice, the entire block is inserted in one shot, there is no logic behind it and the page should be rendered as is (in that code, I've tried to change the tags into <nonscript>
and everything was fine, the head tags isn't been closed and the body tag is opened in the right place, with the right classes.
html wordpress amp-html noscript accelerated-mobile-page
Good day all.
I'm using a "amp" generator on a wordpress site, one of the actions of this plugin is to add a biolerplate tag just before the </head>
and a <noscript>
tag with a fallback.
Google search console keep warning me about a specific error:
"The mandatory tag 'noscript enclosure for boilerplate' is missing or incorrect."
So I start to investigate.
What I've found is that "something" is injecting the </head><body>
just before the <noscript>
opening tag, if I change the place where I put the noscript tag, the other two are moved too.
this is the code rendered:
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style>
</head><body><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
I have done a lot of tests and seems that the <noscript>
tag is the point of this error.
I've read also some other answers that are saying that the document should not be strict xhtml 1.1, which is not the case, infact these are the first things rendered on the page:
<!DOCTYPE html>
<html amp lang="it-IT"><head><meta charset="utf-8"><link rel="dns-prefetch" href="https://cdn.ampproject.org">
I'm trying to figure out what I can do to solve this error that is present across many sites, with different plugins and themes (and also wordpress versions).
UPDATE:
I've tried to add manually a <noscript>
tag in the code, and everytime I add it in the <head>
section, the section get closed, and the <body>
section is opened, without any class (so it's seems like a bug).
if you like to see the bug, just go here and look for the code:
https://www.assistenzamalasanita.com/2015/07/errori-medici-durante-il-parto-come-si-valutano/amp/
UPDATE 2
Disabling ALL plugins and switching to default theme has no effect on this.
Also, I have copied the entire site as is on another server, in which the problem is not present, the WP sites are identical, and also the serer configurations should be, BUT on the site that is working I can see that the HTTP request has an attribute about the php version (7.0.2) which the other site doesn't have.
is that possible that this can influence the rendering of the page??
to see the site that works:
https://www.doors.it/iride/2017/10/risarcimento-malasanita/amp
UPDATE 3
this is the part of the plugin that is actually write the code of the boilerplate (which has the head and body mistaken tags).
add_action( 'amp_post_template_head', 'amp_post_template_add_boilerplate_css' );
function amp_post_template_add_boilerplate_css( $amp_template ) {
?>
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
<?php
}
As you may notice, the entire block is inserted in one shot, there is no logic behind it and the page should be rendered as is (in that code, I've tried to change the tags into <nonscript>
and everything was fine, the head tags isn't been closed and the body tag is opened in the right place, with the right classes.
html wordpress amp-html noscript accelerated-mobile-page
html wordpress amp-html noscript accelerated-mobile-page
edited Sep 25 '18 at 7:07
Matteo Bononi 'peorthyr'
asked Sep 5 '18 at 12:51
Matteo Bononi 'peorthyr'Matteo Bononi 'peorthyr'
88052672
88052672
1
Can you let me know the plugin you are using for AMP?
– Outsource WordPress
Sep 15 '18 at 6:18
AMP for WP - Accelerated Mobile Pages for WordPress
– Matteo Bononi 'peorthyr'
Sep 18 '18 at 8:50
1
You need to provide a Minimal, Complete, and Verifiable example. There is no way for us to tell why the HTML is being inserted in the wrong place without seeing the PHP that is inserting it.
– Quentin
Sep 18 '18 at 10:56
1
The callback/hookamp_post_template_add_boilerplate_css
may have been moved/relocated fromamp_post_template_head
toamp_start
orampforwp_body_beginning
- the latter two would add thenoscript
tag in thebody
and not thehead
. To confirm, try adding this code infunctions.php
:add_action( 'ampforwp_body_beginning', function(){ var_dump( $GLOBALS['wp_filter'] ); } );
and then share/inspect thevar_dump()
output.
– Sally CJ
Sep 18 '18 at 13:43
1
Alright @MatteoBononi'peorthyr', but you can also try this: remove the action -remove_action( 'amp_post_template_head', 'amp_post_template_add_boilerplate_css' )
and copy the entire HTML fromamp_post_template_add_boilerplate_css()
and add it via the settings page/UI - the AMP plugin uses output buffering (so even with manual HTML addition via the UI, thenoscript
might still be pushed into thebody
), but you can try..
– Sally CJ
Sep 19 '18 at 14:53
|
show 16 more comments
1
Can you let me know the plugin you are using for AMP?
– Outsource WordPress
Sep 15 '18 at 6:18
AMP for WP - Accelerated Mobile Pages for WordPress
– Matteo Bononi 'peorthyr'
Sep 18 '18 at 8:50
1
You need to provide a Minimal, Complete, and Verifiable example. There is no way for us to tell why the HTML is being inserted in the wrong place without seeing the PHP that is inserting it.
– Quentin
Sep 18 '18 at 10:56
1
The callback/hookamp_post_template_add_boilerplate_css
may have been moved/relocated fromamp_post_template_head
toamp_start
orampforwp_body_beginning
- the latter two would add thenoscript
tag in thebody
and not thehead
. To confirm, try adding this code infunctions.php
:add_action( 'ampforwp_body_beginning', function(){ var_dump( $GLOBALS['wp_filter'] ); } );
and then share/inspect thevar_dump()
output.
– Sally CJ
Sep 18 '18 at 13:43
1
Alright @MatteoBononi'peorthyr', but you can also try this: remove the action -remove_action( 'amp_post_template_head', 'amp_post_template_add_boilerplate_css' )
and copy the entire HTML fromamp_post_template_add_boilerplate_css()
and add it via the settings page/UI - the AMP plugin uses output buffering (so even with manual HTML addition via the UI, thenoscript
might still be pushed into thebody
), but you can try..
– Sally CJ
Sep 19 '18 at 14:53
1
1
Can you let me know the plugin you are using for AMP?
– Outsource WordPress
Sep 15 '18 at 6:18
Can you let me know the plugin you are using for AMP?
– Outsource WordPress
Sep 15 '18 at 6:18
AMP for WP - Accelerated Mobile Pages for WordPress
– Matteo Bononi 'peorthyr'
Sep 18 '18 at 8:50
AMP for WP - Accelerated Mobile Pages for WordPress
– Matteo Bononi 'peorthyr'
Sep 18 '18 at 8:50
1
1
You need to provide a Minimal, Complete, and Verifiable example. There is no way for us to tell why the HTML is being inserted in the wrong place without seeing the PHP that is inserting it.
– Quentin
Sep 18 '18 at 10:56
You need to provide a Minimal, Complete, and Verifiable example. There is no way for us to tell why the HTML is being inserted in the wrong place without seeing the PHP that is inserting it.
– Quentin
Sep 18 '18 at 10:56
1
1
The callback/hook
amp_post_template_add_boilerplate_css
may have been moved/relocated from amp_post_template_head
to amp_start
or ampforwp_body_beginning
- the latter two would add the noscript
tag in the body
and not the head
. To confirm, try adding this code in functions.php
: add_action( 'ampforwp_body_beginning', function(){ var_dump( $GLOBALS['wp_filter'] ); } );
and then share/inspect the var_dump()
output.– Sally CJ
Sep 18 '18 at 13:43
The callback/hook
amp_post_template_add_boilerplate_css
may have been moved/relocated from amp_post_template_head
to amp_start
or ampforwp_body_beginning
- the latter two would add the noscript
tag in the body
and not the head
. To confirm, try adding this code in functions.php
: add_action( 'ampforwp_body_beginning', function(){ var_dump( $GLOBALS['wp_filter'] ); } );
and then share/inspect the var_dump()
output.– Sally CJ
Sep 18 '18 at 13:43
1
1
Alright @MatteoBononi'peorthyr', but you can also try this: remove the action -
remove_action( 'amp_post_template_head', 'amp_post_template_add_boilerplate_css' )
and copy the entire HTML from amp_post_template_add_boilerplate_css()
and add it via the settings page/UI - the AMP plugin uses output buffering (so even with manual HTML addition via the UI, the noscript
might still be pushed into the body
), but you can try..– Sally CJ
Sep 19 '18 at 14:53
Alright @MatteoBononi'peorthyr', but you can also try this: remove the action -
remove_action( 'amp_post_template_head', 'amp_post_template_add_boilerplate_css' )
and copy the entire HTML from amp_post_template_add_boilerplate_css()
and add it via the settings page/UI - the AMP plugin uses output buffering (so even with manual HTML addition via the UI, the noscript
might still be pushed into the body
), but you can try..– Sally CJ
Sep 19 '18 at 14:53
|
show 16 more comments
1 Answer
1
active
oldest
votes
As the comments have suggested and the third edit says, this is being caused by a hooked function. Luckily that typically is a pretty straightforward fix!
Like @sally-cj mentioned in the comments, use remove_action( 'amp_post_template_head', 'amp_post_template_add_boilerplate_css' );
to stop this function from firing altogether.
If we didn't want to enter in the styles into the admin, you could just duplicate the filter in your theme code without the offending </noscript>
tag.
add_action( 'amp_post_template_head', 'so_52185596_custom_boilerplate_css' );
function so_52185596_custom_boilerplate_css( $amp_template ) {
?>
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style>
<?php
}
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52185596%2fwordpress-adding-a-noscript-tag-makes-the-head-tag-autoclose%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
As the comments have suggested and the third edit says, this is being caused by a hooked function. Luckily that typically is a pretty straightforward fix!
Like @sally-cj mentioned in the comments, use remove_action( 'amp_post_template_head', 'amp_post_template_add_boilerplate_css' );
to stop this function from firing altogether.
If we didn't want to enter in the styles into the admin, you could just duplicate the filter in your theme code without the offending </noscript>
tag.
add_action( 'amp_post_template_head', 'so_52185596_custom_boilerplate_css' );
function so_52185596_custom_boilerplate_css( $amp_template ) {
?>
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style>
<?php
}
add a comment |
As the comments have suggested and the third edit says, this is being caused by a hooked function. Luckily that typically is a pretty straightforward fix!
Like @sally-cj mentioned in the comments, use remove_action( 'amp_post_template_head', 'amp_post_template_add_boilerplate_css' );
to stop this function from firing altogether.
If we didn't want to enter in the styles into the admin, you could just duplicate the filter in your theme code without the offending </noscript>
tag.
add_action( 'amp_post_template_head', 'so_52185596_custom_boilerplate_css' );
function so_52185596_custom_boilerplate_css( $amp_template ) {
?>
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style>
<?php
}
add a comment |
As the comments have suggested and the third edit says, this is being caused by a hooked function. Luckily that typically is a pretty straightforward fix!
Like @sally-cj mentioned in the comments, use remove_action( 'amp_post_template_head', 'amp_post_template_add_boilerplate_css' );
to stop this function from firing altogether.
If we didn't want to enter in the styles into the admin, you could just duplicate the filter in your theme code without the offending </noscript>
tag.
add_action( 'amp_post_template_head', 'so_52185596_custom_boilerplate_css' );
function so_52185596_custom_boilerplate_css( $amp_template ) {
?>
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style>
<?php
}
As the comments have suggested and the third edit says, this is being caused by a hooked function. Luckily that typically is a pretty straightforward fix!
Like @sally-cj mentioned in the comments, use remove_action( 'amp_post_template_head', 'amp_post_template_add_boilerplate_css' );
to stop this function from firing altogether.
If we didn't want to enter in the styles into the admin, you could just duplicate the filter in your theme code without the offending </noscript>
tag.
add_action( 'amp_post_template_head', 'so_52185596_custom_boilerplate_css' );
function so_52185596_custom_boilerplate_css( $amp_template ) {
?>
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style>
<?php
}
add_action( 'amp_post_template_head', 'so_52185596_custom_boilerplate_css' );
function so_52185596_custom_boilerplate_css( $amp_template ) {
?>
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style>
<?php
}
add_action( 'amp_post_template_head', 'so_52185596_custom_boilerplate_css' );
function so_52185596_custom_boilerplate_css( $amp_template ) {
?>
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style>
<?php
}
answered Nov 17 '18 at 5:43
GFargoGFargo
18128
18128
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52185596%2fwordpress-adding-a-noscript-tag-makes-the-head-tag-autoclose%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Can you let me know the plugin you are using for AMP?
– Outsource WordPress
Sep 15 '18 at 6:18
AMP for WP - Accelerated Mobile Pages for WordPress
– Matteo Bononi 'peorthyr'
Sep 18 '18 at 8:50
1
You need to provide a Minimal, Complete, and Verifiable example. There is no way for us to tell why the HTML is being inserted in the wrong place without seeing the PHP that is inserting it.
– Quentin
Sep 18 '18 at 10:56
1
The callback/hook
amp_post_template_add_boilerplate_css
may have been moved/relocated fromamp_post_template_head
toamp_start
orampforwp_body_beginning
- the latter two would add thenoscript
tag in thebody
and not thehead
. To confirm, try adding this code infunctions.php
:add_action( 'ampforwp_body_beginning', function(){ var_dump( $GLOBALS['wp_filter'] ); } );
and then share/inspect thevar_dump()
output.– Sally CJ
Sep 18 '18 at 13:43
1
Alright @MatteoBononi'peorthyr', but you can also try this: remove the action -
remove_action( 'amp_post_template_head', 'amp_post_template_add_boilerplate_css' )
and copy the entire HTML fromamp_post_template_add_boilerplate_css()
and add it via the settings page/UI - the AMP plugin uses output buffering (so even with manual HTML addition via the UI, thenoscript
might still be pushed into thebody
), but you can try..– Sally CJ
Sep 19 '18 at 14:53