<?php
// If there's no $wp_query available..
if(!$wp_query)
// ... then globalise it, so we can read from it (this is just avoids having to catch any problem later, if it should occur (ie. the variable is outside the scope of where it's being called))
global $wp_query;
// Query posts defines parameters for "the loop" query, should you want to over-ride, change, remove or add any to it...
query_posts( array_merge( array('post_type'=>'page') , $wp_query->query ) );
?>
NOTE: query_posts, would typically go before the line if( have_posts() )
… Ignore posts you see that place it after if( have_posts() )
as that’s totally incorrect, as i’ve tried to point out before.. ??
Array merge, joins 2 arrays, giving the first in the merge priority, if a matching array key exists in both arrays, the first array’s key wins. In this case we’re merging post_type into the existing queries arguments, if any post_type arg/parameter exists then it’s overwritten by the new value, because it’s in the first array.
$wp_query->query
Is a class variable (methods are functions), of the wp_query object …
Methods or variables inside an object (Google PHP OOP for more) are like associative arrays only there are some obvious differences (again see OOP related info). Namingly, you’ll notice when you reference a variable (or key if you like) in an object, you use ->
ito reference the item in the object..
eg. When you see lines like.. $post->ID
, it’s referring to the ID variable inside the $post object..
Each PHP function and WP function has an associated document (songdogtech provided one for WP_Query), but i don’t think you’ll make any sense of them without reading through each (it would be a little like explaining what a steering wheel is to someone who has no idea what a car is)… bad analogy aside, hope that helps..
P.S. If you wanted a break down on the code, you could simply have asked in your other thread, i’d not be offended… ?? … (just so you know)..