{"id":3687,"date":"2017-09-14T11:23:49","date_gmt":"2017-09-14T11:23:49","guid":{"rendered":"https:\/\/ampforwp.com\/tutorials\/?post_type=ht_kb&#038;p=3687"},"modified":"2020-05-07T05:28:04","modified_gmt":"2020-05-07T05:28:04","slug":"detect-amp-page-function","status":"publish","type":"ht_kb","link":"https:\/\/ampforwp.com\/tutorials\/article\/detect-amp-page-function\/","title":{"rendered":"How to detect if it&#8217;s AMP page with Function?"},"content":{"rendered":"\n<p>If you are developing some code and you want to detect if it&#8217;s AMP then you can use the below code.<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;php&quot;,&quot;mime&quot;:&quot;text\/x-php&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;PHP&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;php&quot;}\">if ( function_exists( 'ampforwp_is_amp_endpoint' ) &amp;&amp; ampforwp_is_amp_endpoint() ) {\n}<\/pre><\/div>\n\n\n\n<h3>Warning: is_amp_endpoint() is depreciated from AMPforWP<\/h3>\n\n\n\n<p>If you are facing any warnings in the debug log or on the website like<\/p>\n\n\n\n<p><strong>Notice: is_amp_endpoint was called &lt;strong&gt;incorrectly&lt;\/strong&gt;. is_amp_endpoint() is deprecated from AMPforWP, please use ampforwp_is_amp_endpoint instead. Please see &lt;a href=&#8221;https:\/\/codex.wordpress.org\/Debugging_in_WordPress&#8221;&gt;Debugging in WordPress&lt;\/a&gt; for more information.<\/strong><\/p>\n\n\n\n<p>Then to solve this warning, go to the path mentioned in the warning and&nbsp; find <strong>is_amp_endpoint<\/strong> and replace it with <strong>ampforwp_is_amp_endpoint<\/strong><\/p>\n\n\n\n<p>This will fix the warnings.<\/p>\n\n\n\n<p>Hope it helps. If you have any questions, then please ask us in the below comments.<\/p>\n<div id=\"div-1\" class=\"hkb-feedback\">\n\t\t\t<strong class=\"ht-mobile-exit__title\">Ask your Questions Directly!<\/strong><br>\n\t\t\t<div class=\"hkb_widget_exit__content\" style=\"font-size: 14px;\">If you can't find the solutions in this article, then just ask us in the comments and we will answer it for you!<\/div>\n\t\t\t<a href=\"https:\/\/ampforwp.com\/support\/#contact\" id=\"button\" target=\"_blank\" rel=\"noopener noreferrer\"><button>Yes, I have a Question<\/button><\/a>\n\t\t<\/div>","protected":false},"excerpt":{"rendered":"<p>If you are developing some code and you want to detect if it&#8217;s AMP then you can use the below code. Warning: is_amp_endpoint() is depreciated from AMPforWP If you are facing any warnings in the debug log or on the website like Notice: is_amp_endpoint was called &lt;strong&gt;incorrectly&lt;\/strong&gt;. is_amp_endpoint() is deprecated&#8230;<\/p>\n","protected":false},"author":1,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":[],"ht-kb-category":[183],"ht-kb-tag":[],"_links":{"self":[{"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/ht-kb\/3687"}],"collection":[{"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/comments?post=3687"}],"version-history":[{"count":11,"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/ht-kb\/3687\/revisions"}],"predecessor-version":[{"id":17243,"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/ht-kb\/3687\/revisions\/17243"}],"wp:attachment":[{"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/media?parent=3687"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/ht-kb-category?post=3687"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/ht-kb-tag?post=3687"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}