WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] WP_Query (2 posts)

  1. cstoltenkamp
    Member
    Posted 1 year ago #

    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.

  2. cstoltenkamp
    Member
    Posted 1 year ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic