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?
I was facing the same issue and I solved it using ‘post_title’ instead of ‘title’.
check whether you have used
parse_query
orpre_get_posts
hook somewhere in the website