• Resolved cstoltenkamp

    (@cstoltenkamp)


    Hello

    I use WP_Query() with a predefined $Arg array()
    Like $q = array(
    “paged”=>$var_paged,
    “post_per_page”=>$var_paged,
    “orderby”=>$var_orderby,
    “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.

Viewing 1 replies (of 1 total)
  • Thread Starter cstoltenkamp

    (@cstoltenkamp)

    Found, fieldname where false.
    With debugging query.php I found the fault.
    Orderby title is not orderby post_title but just orderby title!

Viewing 1 replies (of 1 total)
  • The topic ‘WP_Query’ is closed to new replies.