1

I have the following object, and I'm trying to get some values from it. Here is a snippet:

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 

How would I get:

[paged] => 1?

I have tried the following, but neither work:

$category_query->paged; $category_query->query->paged; 

3 Answers 3

2

Since you have to traverse objects with -> and arrays with [ ]:

$category_query->query['paged']; 

Because $category_query is an object and query is an array.

Sign up to request clarification or add additional context in comments.

Comments

0

Just try with:

$category_query->query['paged']; 

Comments

0

It is an object of arrays so you'd need to do.. $category_query->query['paged'];

Traverse objects with -> and arrays with [ ]

Comments