I use WP_Query() with a predefined $Arg array()
Like $q = array(
“order” => $var_order);
Before I pass the $q var I see in my debugger the right values.
Then a call new Wp_Query($q), that works for the order, vars paged and post_per_page, but orderby is ignored.
If a do
$query = new WP_Query( array ( ‘orderby’ => ‘title’, ‘order’ => ‘DESC’ ) )
it works …. why is there a different, I did not try it with paged etc.
Also I like to know how to pass a date range to WP_Query.
Now I use add_filter like $filter = add_filter(‘posts_where’, ‘filter_where’);
where filter where returns this string
$where .= ‘ AND post_date >= “‘.$_GET[‘iDate’].'” AND post_date <= “‘.$_GET[‘oDate’].'” ‘ ;
My idea is that there are several solutions to query WordPress and that I mix-up that in a way it not works correct.
I hope someone can help me out.
- The topic ‘[Resolved] WP_Query’ is closed to new replies.