如何在Buddypress上显示添加页面的分页

How to display the pagination of the added page on Buddypress

我在 Wordpress 4.6.1 上使用 Buddypress 2.7.2。 我在 BuddyPress 上使用 bp_core_new_nav_item() 的函数添加了一个新页面来扩展页面。
在该页面上,每页有十个Post类型的文章,分页显示在页面下方。 但是,如果我点击页面的第 2 页或后面的页面,我找不到 link 目的地。我在添加页面写了如下

<?php
$paged = get_query_var('paged');
$args = array(
    'posts_per_page' => 10,
    'paged' => $paged,
    'orderby' => 'post_date',
    'order' => 'DESC',
    'post_type' => 'post',
    'post_status' => 'publish'
);
$the_query = new WP_Query($args);

if ( $the_query->have_posts() ) :
    while ( $the_query->have_posts() ) : $the_query->the_post(); ?>

<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>
<?php
$big = 999999999; // need an unlikely integer

echo paginate_links( array(
    'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
    'format' => '?paged=%#%',
    'current' => max( 1, get_query_var('paged') ),
    'total' => $the_query->max_num_pages
) );
?>

<?php else: ?>
<?php get_template_part( 'content', 'none' ); ?>
<?php endif; ?>

例如分页link如下
第 1 页
首页不是问题。
[这不是 link](http://example.com/member/username/custom/
2 页后
link 目的地不存在。
[这不是link](http://example.com/member/username/custom/page/2/ page/3/ page/4/ .......

不知道为什么找不到第2页或以后的。 如果您知道解决方案,请告诉我。

这是在您的情况下处理分页的一种方法。这可能不是最好的或 'correct' 方式...

$paged 值添加到 url。

例如:

$paged = ( isset( $_GET['xj'] ) ) ? $_GET['xj'] : 1;
$args = array( ... etc. 

然后调整您的分页以使用该变量:

echo paginate_links( array(
        'base' => esc_url( add_query_arg( 'xj', '%#%' ) ),
        'format' => '',
        'total' => ceil( (int) $wp_query->found_posts / (int) get_query_var('posts_per_page') ),
        'current' => (int) get_query_var('paged'),
    ) );