There is an ORDER BY
clause in that query that should not have been generated by those arguments. Plus, it doesn’t look like a WordPress query– note the capitalization. WordPress tends to use all uppercase for SQL functions and operators.
I suspect that there is a filter on posts_orderby
or posts_clauses
that is altering that query when it should not be. When I test your query the ORDER BY
clause is what you would expect from those arguments– ORDER BY wp_posts.posts_modified
— which lends weight to the theory that something is mucking up the query.
Find the function that is altering the query, post it, and I will modify the answer. Look for add_filter('posts_orderby'
or add_filter('posts_clauses'
in your plugins and theme.
As written, that function overwrites the ORDER BY
for most every query. It is difficult to tell where/when that filter is supposed to run, but restricting it to the main query and to categories ought to help.
function category_filter_orderby($orderby) {
if (is_main_query() || is_category()) {
global $wpdb;
//return "post_date DESC";
$orderby = "(select $wpdb->postmeta.meta_value from $wpdb->postmeta where $wpdb->postmeta.post_id=$wpdb->posts.ID and $wpdb->postmeta.meta_key = 'featured_c') ASC,post_date DESC";
}
return $orderby;
}
I don’t know if that should be an OR (||
) or an AND (&&
), or if there should be other conditionals. I’d have to read the mind of the theme designer to tell.