AMP 警告为 "An AMP component 'script' tag is present more than once in the document"
AMP warning as "An AMP component 'script' tag is present more than once in the document"
自上个月以来,我在 AMP 页面中遇到了一个警告问题,因为“AMP 组件 'script' 标记在文档中多次出现。” .i 试图从 AMP 中删除重复的脚本,但无法找到。我不知道它来自插件还是其他地方的天气...
要停止自动注入,只需将以下代码添加到您的 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;
} );
参考:Click Here
自上个月以来,我在 AMP 页面中遇到了一个警告问题,因为“AMP 组件 'script' 标记在文档中多次出现。” .i 试图从 AMP 中删除重复的脚本,但无法找到。我不知道它来自插件还是其他地方的天气...
要停止自动注入,只需将以下代码添加到您的 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;
} );
参考:Click Here