重新分配网址分页后不起作用 [英] After redirct url pagination not working

查看:78
本文介绍了重新分配网址分页后不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的分页代码.重定向页面网址后效果很好.当我将url重定向到另一个页面时,此代码无法正常工作.此自定义分页.

This is my pagination code. It's worked well after redirect page url. When I am redirecting url to another page this code not worked. This custom post pagination.

在重定向分页悬浮URL之前,是: http://xxxx/?industry = 26& posts_per_page = 12& page = 3

before redirect the pagination hover url was: http://xxxx/?industry=26&posts_per_page=12&page=3

,并且重定向后,分页悬浮网址是(并且不起作用): http://xxxx/newpage/? page = 2& industry = 26& location_company = 0& employee = 0 = 0& type = video

and after redirect the pagination hover url was (and its not working): http://xxxx/newpage/?page=2&industry=26&location_company=0&employees=0&type=video

 <?php
                        echo  paginate_links( [
                            'prev_text'          => __( 'Previous', 'bizcast' ),
                            'next_text'          => __( 'Next', 'bizcast' ),
                            'before_page_number' => '',
                            'screen_reader_text' => '',
                            'total' => $videos->max_num_pages,
                            'format'       => '?page=%#%',
                            'current' => ($_GET['page'] ? $_GET['page'] : 1),
                            'type' => 'list'
                        ] );
                        ?>

推荐答案

添加

$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; 

在循环开始之前,在wp查询参数中添加'paged'=> $ paged. 例如:

before loop start and add 'paged' => $paged in wp query arguments. For example:

$paged = ( get_query_var('page') ) ? get_query_var('page') : 1;
$query_args = array(
  'post_type' => 'post',
  'category_name' => 'tutorials',
  'posts_per_page' => 5,
  'paged' => $paged
);

这篇关于重新分配网址分页后不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆