Support » Plugin: AMP » Pagination ( NEXT / PREVIOUS )

  • Resolved othqsa95

    (@othqsa95)


    Hello, I want to install the AMP plugin, but I had read in several forums that Pagination NEXT to Back is not available ..

    Is there a way to apply it?

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

    (@westonruter)

    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.

    Plugin Author Weston Ruter

    (@westonruter)

    And here’s one quick way you can ensure the post links are 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() ) {
    		$url = amp_get_permalink( $post->ID );
    	}
    	$recursing = false;
    	return $url;
    }, 10, 2 );
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Pagination ( NEXT / PREVIOUS )’ is closed to new replies.