Skip to content

Instantly share code, notes, and snippets.

@Manoz
Created February 2, 2014 14:45
Show Gist options
  • Select an option

  • Save Manoz/8769413 to your computer and use it in GitHub Desktop.

Select an option

Save Manoz/8769413 to your computer and use it in GitHub Desktop.
<?php
/**
* Allow parameters to be passed in the URL
*/
add_filter('query_vars', 'parameter_queryvars' );
function parameter_queryvars( $qvars ) {
$qvars[] = 'full'; // This is the parameter for the url: yourblog.com/your-post/?full=1
return $qvars;
}
/**
* Custom paginated posts links
*/
if ( ! function_exists( 'manoz_content_nav' ) ):
function manoz_content_nav() {
$paginated = wp_link_pages(
array(
'before' => '<div class="page-links"> <span>Pages:</span>',
'after' => '</div>',
'next_or_number' => 'number',
'echo' => '0'
)
);
$paginated = str_replace(
'</div>',
'<a href="'.get_permalink().'?full=1"> Full post</a></div>',
$paginated
);
echo $paginated;
}
endif; // manoz_content_nav
?>
<?php
/* Replace <?php the_content(''); ?> with this */
global $wp_query;
if (isset($wp_query->query_vars['full'])) { $n_pagination = $wp_query->query_vars['full']; };
if($n_pagination) {
// If post is paginated, echo the_content and the nav links
echo apply_filters('the_content',$post->post_content);
$page=$numpages+1;
} else {
// If post is NOT paginated, just echo the_content
the_content('');
};
manoz_content_nav();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment