Apply function.php filter only if url not has /amp/
I applied a filter to remove theme styles and javascript in function.php, but I want this to happen only if the url not ends with /amp/
I applied a filter to remove theme styles and javascript in function.php, but I want this to happen only if the url not ends with /amp/
What is amp
? Is it tag or category or page? You should use standard wordpress functions like is_page()
is_category()
is_tag()
.
You can also use $wp->request
. It will return the request URI. If the address is "http://example.com/slug1/slug2"
it will return slug1/slug2
then use explode()
function to split it.
<?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
}
?>
Remember $wp is a global variable so if you want to use it inside a function the must use the keyword global
before it.
Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.