我希望有人能帮助我的评论分页。我有分页工作和链接指向下一页等,但当点击页面只是刷新。这是我目前的代码,希望有人能帮助我。
$pid = $post->ID;
$comment_query = "SELECT * FROM `wp_comments` WHERE comment_post_ID = ".$pid. " AND comment_approved = \'1\'";
$comments_array = $wpdb->get_results($comment_query, OBJECT);
if ($comments_array):
$cpp = 10; // Comments per page
$wp_query->comments = count($comments_array);
//echo $wp_query->found_posts;
$wp_query->max_num_pages = ceil($wp_query->comments / $cpp);
$on_page = intval(get_query_var(\'paged\'));
if($on_page == 0){ $on_page = 1; }
$offset = ($on_page-1) * $cpp;
$wp_query->request = "
SELECT * FROM `wp_comments` WHERE comment_post_ID = ".$pid. " AND comment_approved = \'1\'
LIMIT $cpp
OFFSET $offset
";
$newcomments = $wpdb->get_results($wp_query->request, OBJECT);
?>
<div class="comments">
<?php if ($newcomments) : ?>
<a name="comments" id="comment_anchor"></a>
<h3 class="section-title"><?php _(comments_number(\'No <span>Comments</span>\',\'1 <span>Comment</span>\',\'% <span>Comments</span>\')); ?></h3>
<ul class="comment-container">
<?php
foreach ($newcomments as $comment) :
完整代码:
http://pastebin.com/md3zdpbd 谢谢