Support » Plugin: AMP for WP - Accelerated Mobile Pages » Enabling and Disabling AMP for selected Post

  • Hey guys, I totally love your plugin. I just want to know how to turn off AMP version for selected pages. I want AMP pages only for certain webpages. Thanks for the plugin though.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Contributor ampforwp

    (@ampforwp)

    Hi @abhishekchand,

    Thank you very much for your support and love towards us.

    Coming to your question, if you want to hide AMP for a particular page then in the pages options select that particular page and select Hide for “Show AMP for Current Page?” option(as shown here). It will solve your problem.

    I hope it helps.

    Regards,
    Team AMP

    Hi all, first of all, many thanks for this pluggin!

    I have the same problem with v.0.9.32. In my case I have a webpage with diferent post_types (posts, pages, product, portfolio).
    Post: works with AMP, great!
    Pages: I am select (hide) with option (Show AMP for Current Page?), great again!
    Product and portfolio: can’t disable AMP version because there are no option (Show AMP for Current Page?) in sidebar of this posts type.

    I’m thinking if there are any option to disable AMP version (<link rel=”amphtml”…) in all custom_post_type, for exemple, function like this:

     
      if (is_post_type('portfolio') || is_post_type('product')){
        remove_action( 'amp_post_template_head', 'amp_post_template_add_canonical' );
      } 
    

    Or any way to do it??

    Thanks in advance!

    Regards,

    Plugin Contributor ampforwp

    (@ampforwp)

    Hi @gcasasi,

    Thank you so much for your valuable feedback.
    We have created a ticket about it in our Github and will add this in our next updates(ref).

    Regards,
    Team AMP

    Plugin Contributor ampforwp

    (@ampforwp)

    Hi @gcasasi,

    Can you tell us how you have enabled custom post type in AMP??

    Regards,
    Team AMP

    Hi, thanks for you answer, I try to explain with some examples…

    “portfolio post_type”, can see an example here. If you look code of page, you can see on head section (<link rel=”amphtml” href=”xxxxx/amp/”/>)

    This code generates some google webmaster tools errors, because the page redirect to non-amp page…

    If I use this code (now I leave this code enabled…):

    
    add_action( 'amp_init', 'amp_custom_post_type_support' );
    function amp_custom_post_type_support() {
        add_post_type_support( 'portfolio', AMP_QUERY_VAR );
    }

    AMP works for “portfoio” post_type, I am see AMP version of this page in /amp/.

    My question is, how can I hide (<link rel=”amphtml” href=”xxxxxx/amp/”/>) of this post or all “post_type=portfolio”? There is no option (Show AMP for Current Page?) in sidebar of this posts type on edit post page.

    Thanks

    • This reply was modified 5 years, 8 months ago by Gabri.

    Hi again, I solved the problem with dirty solution because I don’t find any way to create function.

    I edit (./templates/features.php:87) to add some conditional

    if ( || get_post_type( $post->ID ) == ‘post_type’)

    In my case:

    if( $ampforwp_amp_post_on_off_meta['ampforwp-amp-on-off'][0] === 'hide-amp' || get_post_type( $post->ID ) == 'portfolio' || get_post_type( $post->ID ) == 'product' || get_post_type( $post->ID ) == 'cool_timeline')

    also, to know all diferents post_type I can check DB first

    select distinct post_type from wp_posts

    Now, it works like I want, any product/portfolio/… have AMP disabled (because there are no amphtml link on head)

    I hope to find a more optimal solution with your help.

    • This reply was modified 5 years, 8 months ago by Gabri.
    • This reply was modified 5 years, 8 months ago by Gabri.
    Plugin Contributor ampforwp

    (@ampforwp)

    Hi @gcasasi,

    Thank you so much for sharing with us your valuable solution.

    I will discuss it with my team and will try to add this solution in our next updates.

    Regards,
    Team AMP

    Hi again, I just updated to Version 0.9.43.6 and I change again code in features.php because I have a lot of 404 errors with blog archive pages, for example:

    mydomain.com/es/blog/ –> AMP –> mydomain.com/es/blog/amp/ = OK
    mydomain.com/es/blog/page/2 –> AMP –> mydomain.com/amp/es/blog/page/2 = e404
    mydomain.com/es/blog/page/3 –> AMP –> mydomain.com/amp/es/blog/page/3 = e404

    I only want AMP in single posts, for this I just edit (./templates/features.php:157)
    if( get_post_type( $post->ID ) == 'post' && $post->ID != is_home()) {

    Now works fine, thanks again!
    Gabri

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Enabling and Disabling AMP for selected Post’ is closed to new replies.