什么是amp? 是标签、类别还是页面?您应该使用标准的wordpress函数,如is_page() is_category() is_tag().
您也可以使用$wp->request. 它将返回请求URI。如果地址是"http://example.com/slug1/slug2" 它会回来的slug1/slug2 然后使用explode() 函数将其拆分。
<?php $uri = $wp->request;
$slugs = explode("/",$uri);//variable $slugs will have array of slugs
//$slugs[count($slugs)-1] will return last slug
if($slugs[count($slugs)-1] != "amp") {
//Apply your filter filter here
}
?>
记住$wp是一个全局变量,因此如果要在函数中使用它,必须使用关键字
global 在它之前。