Add paging links above comments list. Props Viper007Bond. fixes #8219

git-svn-id: http://svn.automattic.com/wordpress/trunk@10097 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-12-07 04:49:22 +00:00
parent e9e703969b
commit 9f56c8eba4
3 changed files with 13 additions and 1 deletions

View File

@ -20,9 +20,15 @@
<?php if ( have_comments() ) : ?> <?php if ( have_comments() ) : ?>
<h3 id="comments"><?php comments_number('No Responses', 'One Response', '% Responses' );?> to &#8220;<?php the_title(); ?>&#8221;</h3> <h3 id="comments"><?php comments_number('No Responses', 'One Response', '% Responses' );?> to &#8220;<?php the_title(); ?>&#8221;</h3>
<div class="navigation">
<div class="alignleft"><?php previous_comments_link() ?></div>
<div class="alignright"><?php next_comments_link() ?></div>
</div>
<ol class="commentlist"> <ol class="commentlist">
<?php wp_list_comments(); ?> <?php wp_list_comments(); ?>
</ol> </ol>
<div class="navigation"> <div class="navigation">
<div class="alignleft"><?php previous_comments_link() ?></div> <div class="alignleft"><?php previous_comments_link() ?></div>
<div class="alignright"><?php next_comments_link() ?></div> <div class="alignright"><?php next_comments_link() ?></div>

View File

@ -513,6 +513,9 @@ function &separate_comments(&$comments) {
function get_comment_pages_count( $comments = null, $per_page = null, $threaded = null ) { function get_comment_pages_count( $comments = null, $per_page = null, $threaded = null ) {
global $wp_query; global $wp_query;
if ( null === $comments && null === $per_page && null === $threaded && !empty($wp_query->max_num_comment_pages) )
return $wp_query->max_num_comment_pages;
if ( !$comments || !is_array($comments) ) if ( !$comments || !is_array($comments) )
$comments = $wp_query->comments; $comments = $wp_query->comments;

View File

@ -1265,6 +1265,9 @@ function next_comments_link($label='', $max_page = 0) {
if ( empty($max_page) ) if ( empty($max_page) )
$max_page = $wp_query->max_num_comment_pages; $max_page = $wp_query->max_num_comment_pages;
if ( empty($max_page) )
$max_page = get_comment_pages_count();
if ( $nextpage > $max_page ) if ( $nextpage > $max_page )
return; return;
@ -1324,7 +1327,7 @@ function paginate_comments_links($args = array()) {
$page = get_query_var('cpage'); $page = get_query_var('cpage');
if ( !$page ) if ( !$page )
$page = 1; $page = 1;
$max_page = $wp_query->max_num_comment_pages; $max_page = get_comment_pages_count();
$defaults = array( $defaults = array(
'base' => add_query_arg( 'cpage', '%#%' ), 'base' => add_query_arg( 'cpage', '%#%' ),
'format' => '', 'format' => '',