Created
February 2, 2014 14:45
-
-
Save Manoz/8769413 to your computer and use it in GitHub Desktop.
WordPress paginated posts + "Full Page" link. Thx to: http://wordpress.org/support/topic/link-to-show-entire-paginated-post-on-one-page?replies=4#post-1483026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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 | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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