WordPress Pagination与Page 1相同

 DXJ健康快乐 发布于 2023-01-31 14:32

我正在努力让WordPress分页工作.

我使用了不同的插件,并尝试调整pagination.php函数中的代码无济于事.

无论到目前为止我使用过什么插件或调整,第2页,第3页等都会显示相同的帖子.

这是pagination.php中的代码

        

以下是主页的博客模板的代码:


                        $cat_string,            // Query for the cat ID's (because you can't use multiple names or slugs... crazy WP!)
                        'posts_per_page'=>$post_count, // Set a posts per page limit
                        'paged'=>$paged,               // Basic pagination stuff.
                       );

                    query_posts($args); ?>

                     

                        

                    

                        

我应该在两个文件中更改什么才能让它显示除第一页之外的任何其他内容?

我会更改阅读窗格设置,但查询帖子功能使用我不知道的动态值.

如何或我可以改变什么来使它工作?

我尝试了这个页面上的解决方案https://wordpress.stackexchange.com/questions/105977/wordpress-pagination-not-working-always-showing-first-pages-content,但无济于事:

这是我将代码更改为:

$cat_string,            // Query for the cat ID's (because you can't use multiple names or slugs... crazy WP!)
                        'posts_per_page'=> 9, // Set a posts per page limit
                        'paged'=>$paged,               // Basic pagination stuff.
                       );

                    $your_query = new WP_Query( $args ); ?>

                    have_posts() ) : while ( $your_query->have_posts() ) : $your_query->the_post(); ?>  

                        

                    

                        

user3229432.. 7

我修好了它.

我在这里找到了解决方法:http: //themeforest.net/forums/thread/pagination-on-wordpress-static-page-set-to-front-page/28120

而不是这样做:

   $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts( array( 'post_type' => 'post', 'paged' => $paged ) );

我这样做了:

if ( get_query_var('paged') ) {

$paged = get_query_var('paged');

} elseif ( get_query_var('page') ) {

$paged = get_query_var('page');

} else {

   $paged = 1;

}

query_posts( array( 'post_type' => 'post', 'paged' => $paged ) );

现在它有效!

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有