Questions tagged «paged»

3
如何确定我是否在分页的首页上?
如何确定我是否在分页的第一页上?我正在使用WP_Pagenavi。我只想在分页的第一页上运行一个函数。我检查了query_var'paged',在此页面上将其设置为0,然后在随后的页面中将其设置为2,3,以此类推(缺少1!)...有人知道一个干净的解决方案吗? 谢谢。

2
如何创建类别登录页面,然后创建帖子页面?
我正在尝试在主题中创建类别模板,如果用户位于存档的第一页上,它将显示静态内容,然后在接下来的页面中显示类别中的帖子。我基本上是想在Wired.com上复制类别行为,其中 http://www.wired.com/category/design是一个登陆页面,而/ category / design / page / 1显示了像您这样的帖子的倒序排列期望在类别存档上。 这里的关键是我不会在首页上显示类别存档中的任何帖子,因此我需要下一页才能从第一篇文章开始。我首先尝试通过使用偏移量和手动分页来执行此操作,如果'paged'查询变量为2,则将查询的偏移量设置为0。但是,将偏移量设置为零时会忽略偏移量,因此我能做的最好的就是将偏移量设置为1,然后从类别中的第二个帖子开始。 这是我添加到functions.php中的内容: add_action('pre_get_posts', 'category_query_offset', 1 ); function category_query_offset(&$query) { // Before anything else, make sure this is the right query if (!$query->is_category('news')) { return; } // Next, determine how many posts per page $ppp = get_option('posts_per_page'); //Next, detect and handle pagination …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.