• Resolved ronaldlauweb

    (@ronaldlauweb)


    Hello.I’m currently using your plugin to add amp support to a website.
    How can I disable AMP in a specific category? Thanks

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

    (@westonruter)

    Thread Starter ronaldlauweb

    (@ronaldlauweb)

    Thanks, this worked in the category posts, but it doesn’t work in the main category.

    I have the category category-events.php

    Plugin Author Weston Ruter

    (@westonruter)

    I see. OK, so then you’ll want to add this code to your custom theme’s functions.php or a custom plugin:

    add_filter(
    	'amp_supportable_templates',
    	function ( $supportable_templates ) {
    		$supportable_templates['is_category[events]'] = [
    			'label'    => 'Events',
    			'parent'   => 'is_category',
    			'callback' => static function ( WP_Query $query ) {
    				return $query->is_category( 'events' );
    			},
    		];
    		return $supportable_templates;
    	}
    );

    Once that is enabled, then you’ll be able to uncheck the “Serve all templates as AMP regardless of what is being queried.” checkbox and then check all the templates including Category but then leave the Events category under unchecked.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Disable AMP in specific category’ is closed to new replies.