I'm facing an issue the warning in AMP pages since last month as "An AMP component 'script' tag is present more than once in the document.".i tried to remove the duplicate script from the AMP, but cant able to find. i don't know weather it came from the plugin or somewhere else...
Asked
Active
Viewed 1,704 times
1
-
1Hi and welcome to Stack Overflow, please take a time to go through the [welcome tour](https://stackoverflow.com/tour) to know your way around here, read how to create a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) and also check [How to Ask Good Questions](https://stackoverflow.com/help/how-to-ask) so you increase your chances to get feedback and useful answers. – Jacque Feb 22 '19 at 06:11
-
Can you provide the code? – James Ives Feb 24 '19 at 17:06
-
its not a code it just script which has pluggin added itself – Attaulla KF Feb 25 '19 at 08:22
-
filter the js file, can you share the link – Bachcha Singh Feb 27 '19 at 06:40
-
@BachchaSingh Yes Here is link https://truweight.in/blog/weight-loss/6-interesting-health-benefits-of-drinking-hot-water-for-weight-loss.html/amp – Attaulla KF Feb 27 '19 at 08:41
-
Filter amp-form-latest.js – Bachcha Singh Feb 27 '19 at 09:21
1 Answers
2
To stop the auto injection, simply add the following code to your functions.php
add_filter( 'amp_post_template_data', function( $data ) {
$data['amp_component_scripts'] = array_merge(
$data['amp_component_scripts'],
array(
'amp-iframe' => 'https://cdn.ampproject.org/v0/amp-iframe-latest.js',
'amp-analytics' => 'https://cdn.ampproject.org/v0/amp-analytics-latest.js',
'amp-sticky-ad' => 'https://cdn.ampproject.org/v0/amp-sticky-ad-latest.js',
'amp-form' => 'https://cdn.ampproject.org/v0/amp-form-latest.js',
'amp-ad' => 'https://cdn.ampproject.org/v0/amp-ad-latest.js',
)
);
return $data;
} );
Ref : Click Here

Bachcha Singh
- 3,850
- 3
- 24
- 38
-
-
in that case you can put the check : https://developer.wordpress.org/reference/functions/is_page/ – Bachcha Singh Feb 27 '19 at 11:54