Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    The plugin has AMP support.

    1) Your front page is never meant to be AMP’d
    2) The URL structure i shttps://domain.com/slug-category/slug-post/amp/ (at the end)

    What plugin are you using? The URL structure I grabbed is from https://ww.wp.xz.cn/plugins/amp/ – and it’s the recommended structure from Google as well.

    Meanwhile you could just use hooks instead of hacking the plugin. That’s why the hooks are there 🙂

    You could do something like this:

    
    // Flush Varnish
    if ( class_exists( 'VarnishPurger' ) && 'add' !== $screen->action ) {
    	$this->varnish_purge = new VarnishPurger();
    
    	// Generate list of URLs based on the ID:
    	$purgeurls = array( https://domain.com/amp, str_replace('domain.com', 'domain.com/amp', get_permalink( $postId ) ) );
    
    	// Purge 'em all
    	foreach ( $purgeurls as $url ) {
    		$this->varnish_purge->purge_url( $url );
    	}
    }
    

    Not tested, but that’s the basic gist. I run it on a save for the post type in my case, since I have one post type trigger a flush with another.

    Thread Starter duonganhtuan

    (@duonganhtuan)

    I’m using https://ww.wp.xz.cn/plugins/better-amp/ and their AMP’s URL structure is https://domain.com/amp/category-slug/post-slug/ as I mentioned. My AMP pages is indexed and served as well so I think the URL structure is not too important.

    And thanks, I will test your hook and report later.

    • This reply was modified 7 years, 10 months ago by duonganhtuan.
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Better AMP plugin support’ is closed to new replies.