如何在 WordPress 中设置例外,使模板不加载到 AMP 上?

问题描述 投票:0回答:1

我的网页也使用官方插件在 AMP 上完整。我的内容使用模板,每次有人发帖时都会使用该模板。所有页面都在 AMP 中,但如果我希望只有一个模板不在 AMP 中加载,我该如何实现这一点?我尝试使用functions.php但没有成功

html wordpress templates amp-html asynchronous-messaging-protocol
1个回答
0
投票

您可以通过在模板中使用

amp_is_request
来实现这一点。

if ( function_exists( 'amp_is_request' ) && amp_is_request() ) {
   /* AMP Request */
} else {
   /* non AMP Request */
}
© www.soinside.com 2019 - 2024. All rights reserved.