• Resolved Jayme Edwards

    (@jcedwards76)


    Hello,

    I have a site that I built a custom theme for where everything is amp first.

    I need to use a plugin for hosting courses where I won’t have control over the pages, so they won’t be amp compatible.

    But AMP tries to validate these pages.

    Is there a way to add rules to exclude validation (and running amp at all) on pages with certain names, IDs, or post types etc?

    I’ve seen the amp_post_status_default_enabled filter and the add_theme_support(‘amp’) ‘templates_supported’ option, but I’m not quite sure how to do this.

    Any help appreciated, thank you.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Weston Ruter

    (@westonruter)

    Hi. I think you are looking for the amp_skip_post filter. You can use that to turn off AMP for certain posts/pages.

    Plugin Author Weston Ruter

    (@westonruter)

    For example, to prevent AMP on posts the “Foo” category:

    add_filter( 'amp_skip_post', function( $skip, $post ) {
    	if ( has_category( 'foo', $post ) ) {
    		$skip = true;
    	}
    	return $skip;
    }, 10, 2 );
    Thread Starter Jayme Edwards

    (@jcedwards76)

    This is great! Is it possible to skip amp for archive pages too?

    Plugin Author Weston Ruter

    (@westonruter)

    If you are using Standard or Transitional mode, you can turn off AMP for archive pages in the plugin settings screen. Uncheck the checkbox for serving all templates as AMP, and then select the types of templates you want enabled for AMP.

    Otherwise, in the current Reader mode then AMP is not served for archives anyway. (In the upcoming 2.0 version AMP will be available for serving archives if you have a Reader theme selected.)

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Exclude native validation with conditions?’ is closed to new replies.