1

I'm using Buddypress 2.7.2 on Wordpress 4.6.1. I added a new page using the function by bp_core_new_nav_item() on BuddyPress for expanding pages.
On that page, there are ten Post-type artcles each page , the pagination are displayed under the page. However, if I click on page 2 or later of the page, I can not find the link destination. I wrote on the added page as follows.

<?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; ?>

For example, the pagination link is as follows.
Page 1
Top page is not the problem.
[this is not a link](http://example.com/member/username/custom/
After 2 pages
The link destination does not exist.
[this is not a link](http://example.com/member/username/custom/page/2/ page/3/ page/4/ ........

I don't know why I can not find the 2 page or later. If you know the solution, please let me know.

X JAPAN
  • 15
  • 5

1 Answers1

0

This is one way to handle pagination in your situation. It is probably not the best or the 'correct' way...

Add the $paged value to the url.

For example:

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

And then adjust your pagination to use that variable:

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'),
    ) );
shanebp
  • 1,904
  • 3
  • 17
  • 28
  • Thanks to you, I solved about paging. Besides, there is one little question. About the 'format' in which the parameters are displayed. I would like to specify like this 'format' => '/xj/%#% ', . Therefore the displayed URL looks like this [this is not a link](http://example.com/member/username/custom/xj/2/ . Is this display possible with this function paginate_links() ? – X JAPAN Dec 13 '16 at 05:32
  • It is not possible when using the approach I've shown. – shanebp Dec 13 '16 at 13:24