Reputation: 9275
I build a plugin that base on plugin https://wordpress.org/plugins/amp/ and I want to check state when the user on AMP post or page.
What is the function that allows us to check AMP endpoint in WordPress?
Upvotes: 3
Views: 3655
Reputation: 9564
I strongly suggest to use the is_amp_endpoint()
function and wrap it within an existing condition, such as the following:
if (function_exists( 'is_amp_endpoint' ) && is_amp_endpoint()) {
// do stuff
}
That way your Wordpress web site won't crash if/when the WP-AMP plugin gets disabled (or changes its behaviour / method signature).
For additional info and alternative ways to do that, check out this blog post that I wrote on this topic.
Upvotes: 4
Reputation: 541
You can use the is_amp_endpoint()
function to check if the currently loaded page/post is an AMP one.
Upvotes: 6