How can I see all of a post’s comments on a single page as a reader, if pagination is enabled?

Is there an URL I can access, or an argument that can be passed, to disable pagination on the reader’s side?

The blog uses standard WordPress comment pagination, i.e., http://example.com/2012/01/post-title/comment-page-1/

Read More

I’d like to be able to reformulate the URL into something like http://example.com/2012/01/post-title/all-comments

Related posts

Leave a Reply

1 comment

  1. Just build a link that has some query args:

    printf(
         '<a href="http://example.com/all-comments?pid=%s">All comments</a>'
        ,get_the_ID()
    );
    

    Then add a page with a a permalink of all-comments, so you have something to target.

    There you attach a template like the following (just a base to work off):

    <?php
    /**
     * Template Name: All Comments
     */
    
    // Abort if we got no `pid` query arg and redirect
    if ( ! isset( get_query_arg( 'pid' ) ) )
    {
        // We got no referer, so we don't know where to go: Send visitor to home
        if ( 
            ! isset ( $_SERVER["HTTP_REFERER"] )
            OR ! strstr( $_SERVER["HTTP_REFERER"], home_url( '/' ) )
        )
            exit( wp_redirect( home_url( '/' ) ) );
    
        exit( wp_redirect( $_SERVER["HTTP_REFERER"] ) );
    }
    
    // Do something with our comments.
    // So far we just throw some debug output to get insights and see if it's working:
    echo '<pre>'.var_export( get_comments( array( 'post_id' => get_query_arg( 'pid' ) ) ), true ).'</pre>';