我有以下对象,我试图从中获取一些值。这是一个片段:
WP_Query Object
(
[query] => Array
(
[category_name] => Beauty
[numberposts] => -1
[posts_per_page] => 4
[post_type] => post
[post_status] => publish
[orderby] => date
[order] => DESC
[paged] => 1
)
[query_vars] => Array
(
[category_name] => beauty
[numberposts] => -1
[posts_per_page] => 4
[post_type] => post
[post_status] => publish
[orderby] => date
[order] => DESC
[paged] => 1
[error] =>
[m] =>
[p] => 0
[post_parent] =>
[subpost] =>
[subpost_id] =>
[attachment] =>
[attachment_id] => 0
我将如何获得:
[paged] => 1
?
我尝试了以下方法,但都没有工作:
$category_query->paged;
$category_query->query->paged;
答案 0 :(得分:2)
由于您必须遍历->
的对象和[ ]
的数组:
$category_query->query['paged'];
因为$category_query
是一个对象而query
是一个数组。
答案 1 :(得分:0)
试试:
$category_query->query['paged'];
答案 2 :(得分:0)
这是一个数组的对象,所以你需要做..
$category_query->query['paged'];
使用->
遍历对象和使用[ ]