我有个小问题,我有作者页面(example.com/author/joe
) 在此页上I have listed all author comments with pagination 但单击url后分页不起作用-例如。com/author/joe/page/2,页面被重定向到索引。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,
) );