在 Wordpress 中查找当前页码 [英] Finding current page number in Wordpress
本文介绍了在 Wordpress 中查找当前页码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的 Wordpress 模板中添加了以下自定义循环:
I have added the following custom loop in my Wordpress template:
$args = array(
'category__not_in' => array($featured_cat->term_id),
'posts_per_page' => 10,
'post__not_in' => array($recent_post)
);
query_posts($args);
为了分页工作,我想我需要传递另一个带有当前页码的参数 paged
.Wordpress中获取当前页码的方法是什么?
For pagination to work, I guess I need to pass another arg paged
with the current page number. What is the way to get the current page number in Wordpress?
推荐答案
目前不在 wordpress 系统附近进行测试,但您应该可以使用:
Not near a wordpress system to test this out at the mo, but you should be able to use:
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
(显然默认为 1,如果还没有发送通过).
(obviously defaulting to 1, if it has not been sent through).
这篇关于在 Wordpress 中查找当前页码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文