ampproject / amp-wp

Enable AMP on your WordPress site, the WordPress way.
https://wordpress.org/plugins/amp/
GNU General Public License v2.0
1.79k stars 383 forks source link

Need Support for Pagination #507

Closed ActionCoding closed 7 years ago

ActionCoding commented 8 years ago

I have many articles that are very long and on the desktop and responsive versions of my site I am using pagination using the comment block available in wordpress. According to this link:

https://www.ampproject.org/docs/reference/components/amp-live-list

pagination is available on AMP pages. Can we get this implemented using the nextpage comment?

ActionCoding commented 8 years ago

Is there a reason this is not marked a as a high priority? It affects almost every serious blogger!

ActionCoding commented 8 years ago

Can someone please help me figure out how to get the plugin to recognize the built in Wordpress nextpage comments? This is vital to my blog.

ActionCoding commented 8 years ago

Is there anyone that can point me in the right direction as to where I would start. I have no problem working on it myself. Thanks!

AdityaNayak commented 7 years ago

+1 Same issue.

Going with a custom solution at the moment.

theendfear1 commented 7 years ago

@AdityaNayak may i know your custom solution?

AdityaNayak commented 7 years ago

Found a plugin instead on codecanyon. I haven't moved to AMP yet but was able to find a working solution. https://codecanyon.net/item/wp-amp-accelerated-mobile-pages-for-wordpress-and-woocommerce/16278608/support

Let me know if you decide to buy, we can split the costs.

westonruter commented 7 years ago

Here's how nesxt/previous pagination support can be supported in your theme.

In your theme, add a file named amp/post-pagination.php that contains:

<?php the_post_navigation(); ?>

Then in your functions.php add the following snippet:

add_filter( 'amp_post_article_footer_meta', function( $parts ) {
    array_unshift( $parts, 'post-pagination' );
    return $parts;
} );

You'll need to add the desired styling separately.

And you'll probably also want something like this to ensure that the links point to the AMP versions:

add_filter( 'post_link', function( $url, $post ) {
    static $recursing = false;
    if ( $recursing ) {
        return $url;
    }
    $recursing = true;
    if ( ! function_exists( 'post_supports_amp' ) || ! post_supports_amp( $post ) ) {
        return $url;
    }
    if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() && post_supports_amp( $post ) ) {
        $url = amp_get_permalink( $post->ID );
    }
    $recursing = false;
    return $url;
}, 10, 2 );