Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
    
My company developed this plugin, which makes the process even easier: wordpress.org/extend/plugins/page-links-single-page-option –  user15764 May 2 '12 at 17:25

1 Answer 1

up vote 2 down vote accepted

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

share|improve this answer
    
Oh man I looked for this everywhere! Thanks! I'm going to try it tomorrow, see how it works. –  Josh Oct 26 '11 at 0:24
    
I found this plugin wordpress.org/extend/plugins/view-all-posts-pages - have not tested it myself. –  Michael Oct 26 '11 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 Apr 13 '12 at 18:26

protected by Community Oct 20 '12 at 8:46

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

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