I am trying to ORDER BY
my results of a custom select query.
But I am trying to order by the value of a meta key.
Please see my query below…
$get_atts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE $wpdb->posts.post_type IN ('individual') ORDER BY $wpdb->posts.meta_key = 'surname' ASC");
As you can see this ORDER BY
is breaking it…
ORDER BY $wpdb->posts.meta_key = 'surname' ASC"
So I am trying to order by the value of surname
But my does not seem to work. Can any explain why or help?
Try to use this query: