Getting query_vars to pull two category IDs
-
I’m trying to set up a PageOfPosts type template that will pull for two categories at a time. I’ve been searching and searching as to how query_vars is populated, but I haven’t found any documentation.
What I’m doing is using $args to get the two categories. I’ve hard coded in the two that I want right now just to try and get this to work.
`$args=array(
‘category__and’ => ’10, 17′,
‘orderby’ => ‘date’,
…`Then I make the call for a new query (just taken from the normal PageOfPosts template)
$temp = $wp_query; // assign orginal query to temp variable for later use $wp_query = null; $wp_query = new WP_Query($args);
So it seems like it should work, but when I print out the variables it will only take the first value in $args.
This is the top line of print_r($args)
Array ( [category__and] => 10, 17
So $args is correctly populated with what I want.
But when I call print_r($wp_query) I get this
WP_Query Object( [query_vars] => Array( [category__and] => Array( [0] => 10 )
I’ve tried changing the way that $args is setup multiple times, but nothing seems to change, the $query_vars only pulls the first category.
I’m just wondering if anyone can explain how this works so I can get the query_vars to hold the two categories and correctly filter for the posts I want.
- The topic ‘Getting query_vars to pull two category IDs’ is closed to new replies.