• luisangelmanga

    (@iniciopublicxd)


    Hi there,

    How can we check if a user is currently on AMP post? Can we set a condition like:

    if (is_amp_page()) { // do something }

    Is there a way we can do this?

    Many thanks in advance!

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Ahmed Kaludi

    (@ahmedkaludi)

    Yes you can do this by using

    if ( function_exists( 'ampforwp_is_amp_endpoint' ) && ampforwp_is_amp_endpoint() ) {
    } 

    You can take help from this tutorial : https://ampforwp.com/tutorials/article/detect-amp-page-function/

    Thread Starter luisangelmanga

    (@iniciopublicxd)

    it didn’t work out , I’m trying to use it to use a plugin only in AMP :

    Los cambios en tu código PHP se han revertido debido a un error en la línea 28 del archivo wp-includes/query.php. Por favor, arréglalo y trata de guardar de nuevo.

    Uncaught Error: Call to a member function get() on null in wp-includes/query.php:28
    Stack trace:
    #0 wp-content/plugins/accelerated-mobile-pages/accelerated-moblie-pages.php(580): get_query_var(‘amp’, false)
    #1 wp-content/plugins/table-of-contents-plus/toc.php(1764): ampforwp_is_amp_endpoint()
    #2 wp-settings.php(360): include_once(‘/home/mdcbcgzz/…’)
    #3 wp-config.php(78): require_once(‘/home/mdcbcgzz/…’)
    #4 wp-load.php(37): require_once(‘/home/mdcbcgzz/…’)
    #5 wp-admin/admin.php(34): require_once(‘/home/mdcbcgzz/…’)
    #6 wp-admin/plugin-editor.php(10): require_once(‘/home/mdcbcgzz/…’)
    #7 {main}

    Plugin Author Ahmed Kaludi

    (@ahmedkaludi)

    May I know the codes which you have manually added?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Check if on AMP Page’ is closed to new replies.