我有作者页面(example.com/author/joe)我已经列出所有作者的分页评论但是点击了url后分页不起作用 - example.com/author/ joe / page / 2,页面重定向到index.php。
在其他页面中它起作用,仅在此作者页面中遇到问题。
有什么想法吗?
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$number = get_option('comments_per_page');
$offset = ( $paged - 1 ) * $number;
$count = count( get_comments( array(
'user_id' => $user_ID,
'status' => 'approve',
) ) );
$max_total = ceil($count/$number);
$args = array(
'user_id' => $user_ID,
'number' => $number,
'status' => 'approve',
'offset' => $offset,
'paged' => $paged
);
$the_query = new WP_Comment_Query;
$comments = $the_query->query( $args );
foreach($comments as $comment){
//code
}
//Pagination
$big = 999999999;
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $max_total,
'prev_next'=> true,
) );
马特