Adding Variables to post query
As toscho said, you can modify the query in the pre_get_posts hook. That hook gets the query object passed as an argument, so you don’t have to read a global variable. add_action( ‘pre_get_posts’, ‘wpse12692_pre_get_posts’ ); function wpse12692_pre_get_posts( &$wp_query ) { if( isset( $_SESSION[‘size’] ) && $_SESSION[‘size’] != ‘all’ ) { $wp_query->query_vars[‘meta_query’] = array( ‘key’ => … Read more