繁体   English   中英

max_num_pages返回帖子数而不是页面数

[英]max_num_pages returning number of posts instead of number of pages

我正在使用PBD的“加载下一篇文章”插件,并且运行良好,但是我不知道为什么max_num_pages返回44(该类别的帖子数)而不是4(应该是页面数)。 以下是所有相关代码:

http://pastebin.com/ezAbD2eH

这是它正在运行的页面:garthreckers(dot)com / category / united-states /(对不起,代表不足以发布另一个完整链接)

它也在欧洲页面上运行,但在那里返回了20个(再次发布了帖子)。

另外,if(mobile ...)来自mooble插件,如果有所不同。 我已经尝试剥离该代码并停用它,但仍然无法正常工作。

任何帮助将是巨大的,因为我已经尝试解决此问题3天了,但没有成功。

我可能已经找到您的问题。 当前在您的PHP代码中显示所有帖子时,您有一个查询,要求输入类别

wp_list_categories('show_option_none=&orderby=name&show_count=1&hide_empty=1&use_desc_for_title=1&child_of='.$cat.'&title_li=');

目前,它正在根据类别列表编号显示max_num_pages,因此正在淘汰该编号。 我将更改您显示帖子的方式,以使其不使用wp_list_categories来检索它们。

参考: http : //codex.wordpress.org/Template_Tags/get_posts

<?php
$args = array( 'numberposts' => 3 );
$lastposts = get_posts( $args );
foreach($lastposts as $post) : setup_postdata($post); ?>
    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    <?php the_content(); ?>
<?php endforeach; ?>

我知道这可能不是最好的方法,但是如果您愿意,可以更改javascript中的默认数字作为解决方法

您的JS http://pastebin.com/ezAbD2eH

58行:

var max = parseInt(pbd_alp.maxPages);

改成:

var max = parseInt(pbd_alp.maxPages/12);  //divide it by the number of posts per page. 

如果愿意,可以将其设置为变量,并在$ arg也用于其他地方,以便全局设置数字。 在PHP部分中设置$ posts_per_page = 12。

var max = parseInt(pbd_alp.maxPages/<?php echo $posts_per_page; ?>); 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM