- This topic has 12 replies, 3 voices, and was last updated 4 years, 5 months ago by Tom.
-
AuthorPosts
-
November 6, 2019 at 11:29 pm #1055535Junaid
Hello there,
I just installed a plugin that helped me add my ads code to AMP version. But now there is an error with the page in the validator.
Here is the title of the error,
The tag ‘amp-ad extension .js script’ appears more than once in the document. This will soon be an error.
It means that a script is added twice.
Here is the script that I want to filter from the PHP,<script type=’text/javascript’ src=’https://cdn.ampproject.org/v0.js’ async></script>
Can you help me in this regard?
If you want to understand the by your own then please check out this result.
November 6, 2019 at 11:35 pm #1055538JunaidActually, the script is this one,
<script type=’text/javascript’ src=’https://cdn.ampproject.org/v0/amp-ad-0.1.js’ async custom-element=”amp-ad”></script>
This script is appearing at line 39 and 41 in the validator.
November 7, 2019 at 2:15 am #1055619DavidStaffCustomer SupportHi there,
unless you hooked in that code then its being added by a plugin. If the plugin adds the script then you can remove the one you did hook in.
November 7, 2019 at 2:43 am #1055632JunaidI had removed the hooked element. I have tried to disable all other options than a single plugin.
November 7, 2019 at 2:54 am #1055648DavidStaffCustomer SupportDo you have any functions that could be requesting the file?
November 7, 2019 at 3:06 am #1055671JunaidI have only AMP plugins. One is simple AMP plugin by Google and other is AMP incontent Ads by Github.
If you want to check dashboard. I don’t mind it.November 7, 2019 at 4:56 am #1055778DavidStaffCustomer SupportI can only assume that both of those plugins are making the same request.
I also see this a the very bottom of your website: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; } );
Not sure what thats doing there, it looks like it has been added to a Hook. As its PHP it would need to be added to your child themes functions.php
November 7, 2019 at 5:19 am #1055804JunaidYes, I had found this code as a solution somewhere on internet and I added to the hook. Where sbould I place it so that it could work properly?
Secondly, both plugins are not for Ads. Only one is for Ads in AMP.November 7, 2019 at 5:21 am #1055808DavidStaffCustomer SupportThis article explains:
November 7, 2019 at 7:42 am #1056051JunaidThe idea is good, but I couldn’t understand how can I use child theme. I found some information on Google but that’s too much complicated to install a Child Theme. Isn’t there any other way? Should I try adding directly to functions.php?
November 7, 2019 at 6:30 pm #1056461TomLead DeveloperLead DeveloperHi there,
In that case, I would use this plugin: https://wordpress.org/plugins/code-snippets/
November 8, 2019 at 2:12 am #1056650JunaidI don’t know how but the issue is now resolved by it’s own.
Thank you for your support.
November 8, 2019 at 9:54 am #1057186TomLead DeveloperLead DeveloperNo problem 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.