Skip to main content
6 events
when toggle format what by license comment
Jul 18, 2017 at 8:35 comment added Blaine Lafreniere Yes, I want all records regardless of whether the post meta exists or not. No matter how I slice it with meta_query, I either end up with all posts that have meta, or all posts that don't have meta, which isn't what I wanted. I wanted all posts no matter what, and then order the results by meta, putting records without meta last. I ended up writing a function that simply ensures all posts have meta, and set initial popularity to 0 and stickied to 0. Then am I able to order the results correctly using meta_query and orderby with two meta keys.
Jul 18, 2017 at 6:37 history edited Johansson CC BY-SA 3.0
added 700 characters in body
Jul 18, 2017 at 6:31 comment added Johansson Also this and this question are discussing something similar.
Jul 18, 2017 at 6:22 comment added Johansson I'm not sure about that, but I would assume it will also include the posts that do not have a key too, the same way that sorting by title also includes the posts that do not have a title.
Jul 18, 2017 at 5:18 comment added hwl As I read it, OP wants all posts of some type, even those without meta key(s), and only to order by those meta keys as first and second priority, then the rest. If I understand it, meta_key => some_key is handled by WP Meta_Query and excludes posts without that key(s), right?
Jul 18, 2017 at 3:54 history answered Johansson CC BY-SA 3.0