I have such a request:

$args = array( 'posts_per_page'=>1, 'paged' => ( get_query_var('page') ? get_query_var('page') : 1 ), 'post_type' => array('post-pressa','post-metro','post'), 'tax_query' => array( 'relation' => 'AND', array( 'taxonomy' => 'items', 'field' => 'id', 'terms' => array( $term ) ), array( 'taxonomy' => 'category', 'field' => 'id', 'terms' => array( $city ) ), ) ); $query = new WP_Query($args); $max_num_pages = $query->max_num_pages; 

I bring pagination

 <?php global $wp_query; $big = 999999999; $page_args = array( 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 'format' => '?page=%#%', 'current' => max( 1, get_query_var('page') ), 'total' => $max_num_pages ); ?> <?php echo paginate_links($page_args) ?> 

Links of pages are obtained with such www.mysite.ru/my_posts/page/2 and on this link the page gives 404 error

If you manually enter www.mysite.ru/my_posts?page=2 everything works correctly in the admin panel of the "permalinks" WordPress there are arbitrary links.

I tried differently including the option when format' => ''

The question is how to make the pagination work, or to read / page / 2 normally, or to give? Page = 2 but not to the detriment of the work of other ways on the site

  • See how the redirection is configured for page-by-page navigation in global $ wp_rewrite. - zsiteru

1 answer 1

I don’t know how true that was, but I solved the problem by writing my own piece of pagination assembly

 <div class="pagenavi"> <?php $term = get_query_var('term'); //echo $term; $tax = get_query_var('taxonomy'); //echo $tax; $paged = (get_query_var('page')) ? get_query_var('page') : 1; if($max_num_pages>1){?> <?php for($i=1;$i<=$max_num_pages;$i++){?> <?php if($i==1){?> <a href="<?php bloginfo('url');?>/<?php echo $tax;?>/<?php echo $term;?>?<?='id='. $city; ?>" <?php echo ($paged==$i)? 'class="selected"':'';?>><?php echo $i;?></a> <?php }else{?> <a href="<?php bloginfo('url');?>/<?php echo $tax;?>/<?php echo $term;?>?<?php echo 'page=' . $i; ?>&<?='id='. $city; ?>" <?php echo ($paged==$i)? 'class="selected"':'';?>><?php echo $i;?></a> <?php } ?> <?php } } ?>