Reputation: 2008
So I have this query
$args = array(
'post_type' => 'course', // custom post type
'post_status' => 'publish',
'posts_per_page' => -1,
'orderby' => 'title'
);
$courses = new WP_Query($args);
This gives me what I want, but the orderby statement is being ignored. When I dump the $courses->request
I get this
'SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'course' AND ((wp_posts.post_status = 'publish')) ORDER BY wp_posts.menu_order ASC '
It is defaulting the orderby to menu_order instead of title. What's going on here?
Upvotes: 1
Views: 3253
Reputation: 96
I was facing the same issue and I solved it using 'post_title' instead of 'title'.
$args = array(
'post_type' => 'course', // custom post type
'post_status' => 'publish',
'posts_per_page' => -1,
'orderby' => 'post_title' // change here
);
$courses = new WP_Query($args);
Upvotes: 1
Reputation: 2398
check whether you have used parse_query
or pre_get_posts
hook somewhere in the website
add_action( 'pre_get_posts', 'function_name' );
add_filter( 'parse_query', 'function_name' );
Upvotes: 0