4

Okay, so you know how you can break up a wordpress post by inserting the next-page/page break quicktag. Then, using the wp link pages function in your template, wordpress will generate page 1, 2, 3, etc. links for your now paginated post.

Great. But is there any way to put the post back together again? Think about all the online magazines and newspapers that break their articles into pages and then offer some variation on a "single page view." Can you do that with Wordpress? I spent the whole weekend trying to google a solution and came up with exactly nothing.

1

1 Answer 1

2

Yes, it is possible, and I use it on my own site. Here it is in action: my Settings API post is paginated, but can viewed on a single page, using the "Single-Page View" link.

First, you need to prepare a custom query variable, e.g. in functions.php, add the following:

function cbnet_parameter_queryvars( $qvars ) {
    $qvars[] = 'all';
    return $qvars;
}
add_filter( 'query_vars', 'cbnet_parameter_queryvars' );

Second, inside the Loop, you need to replace your basic call to the_content() with the following:

global $wp_query;
$no_pagination = false;
if ( isset( $wp_query->query_vars['all'] ) ) {
    $no_pagination = $wp_query->query_vars['all'];
}
if( $no_pagination ) {
    echo apply_filters( 'the_content', $post->post_content ); 
    $page=$numpages+1;
} else {
    the_content('Read the rest of this entry');
}

Then finally, you need to add a link to generate the single-page view, e.g. next to your "Permalink" and "Comments" links in your Post Meta:

<?php 
global $numpages;
if ( is_singular() && $numpages > 1 ) { ?>
        <strong>|</strong> <a href="<?php echo add_query_arg( array( 'all' => '1'), get_permalink() ); ?>" title="single-page view">Single-Page View</a>
<?php } ?>

Now, when you clock the "Single-Page View" link, the entire post content will appear on a single page.

Note: h/t to this WPORG support forum topic

4
  • Oh man I looked for this everywhere! Thanks! I'm going to try it tomorrow, see how it works.
    – Josh M
    Commented Oct 26, 2011 at 0:24
  • I found this plugin wordpress.org/extend/plugins/view-all-posts-pages - have not tested it myself.
    – Michael
    Commented Oct 26, 2011 at 9:29
  • BRILLIANT... worked like a charm. Thank you so much!! Particularly, thanks for the easy-to-follow instructions. I can hack my way thru this stuff, but your "put this here" "put that there" steps made it so much faster & smoother.
    – user15177
    Commented Apr 13, 2012 at 18:26
  • Chip Bennett, this is my blog listupon.com I am using Genesis framwork, how can I achieve toggle between page navigation (List view) and one page link? just like this example goo.gl/j39Y3w
    – Faisal
    Commented Nov 3, 2015 at 6:57

Not the answer you're looking for? Browse other questions tagged or ask your own question.