• Resolved rmmoul

    (@rmmoul)


    Here are the PHP args used for the query:

    $args = array(
    	'post_type'=>'portfolio',
    	'posts_per_page' => 9,
    	'orderby' => 'title',
    	'order' => 'ASC',
    	'paged' => $paged
    );
    
    $port_posts = new WP_Query( $args );

    Running a var dump gives me this query:

    var_dump($port_posts->request);
    
    string(243) "SELECT SQL_CALC_FOUND_ROWS  wp_posts.ID FROM wp_posts  WHERE 1=1  AND wp_posts.post_type = 'portfolio' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private')  ORDER BY wp_posts.menu_order, wp_posts.post_date DESC LIMIT 0, 9"

    Looking at the SQL that’s produced above, shows that both the “orderby” and the “order” are ignored completely.

    I don’t understand why the orderby gets changed to “wp_posts.menu_order” when it’s clearly set to “title”.

    Has anyone else run into this issue? Looking at the codex shows this as possible, so any help would be awesome.

    http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters

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

    (@rmmoul)

    I found the issue. The client is using this plugin:

    Post Types Order

    Disabling it fixed the issue.

Viewing 1 replies (of 1 total)
  • The topic ‘WP_Query is ignoring "orderby" and "order"’ is closed to new replies.