Timeline for Sort on meta value but include posts that don't have one
Current License: CC BY-SA 3.0
37 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 5, 2022 at 19:53 | answer | added | Adriano Tornatore | timeline score: 0 | |
Oct 18, 2022 at 22:26 | answer | added | purplefeel | timeline score: 1 | |
May 18, 2022 at 7:01 | answer | added | daamsie | timeline score: 0 | |
Jan 3, 2021 at 17:41 | answer | added | mikemike | timeline score: 1 | |
Jul 11, 2020 at 4:51 | answer | added | Jacob Raccuia | timeline score: 0 | |
Oct 28, 2019 at 18:03 | answer | added | jpussacq | timeline score: 0 | |
May 25, 2019 at 19:24 | answer | added | Ilya Kogan | timeline score: 3 | |
Feb 23, 2019 at 16:36 | comment | added | Paul | @powerbuoy please see my answer for a solution. | |
Feb 23, 2019 at 16:33 | answer | added | Paul | timeline score: 9 | |
Jan 12, 2019 at 1:16 | answer | added | KittMedia | timeline score: 1 | |
Apr 18, 2018 at 15:23 | answer | added | noahmason | timeline score: 24 | |
Dec 14, 2017 at 22:11 | comment | added | J.D. | I've opened a trac ticket to possibly add a solution to the core query classes that would make this kind of thing possible: core.trac.wordpress.org/ticket/42907 | |
Jun 7, 2017 at 9:15 | history | edited | powerbuoy | CC BY-SA 3.0 |
added 852 characters in body
|
Jun 7, 2017 at 9:11 | vote | accept | powerbuoy | ||
Apr 13, 2017 at 12:37 | history | edited | CommunityBot |
replaced http://wordpress.stackexchange.com/ with https://wordpress.stackexchange.com/
|
|
Aug 20, 2015 at 16:17 | answer | added | rjpedrosa | timeline score: 1 | |
Jul 31, 2014 at 5:32 | answer | added | binki | timeline score: 12 | |
Apr 20, 2014 at 14:01 | answer | added | Steven Jones | timeline score: 5 | |
Apr 15, 2014 at 20:38 | comment | added | powerbuoy | Oh ok thanks. This was for a project I've since long finished but I'll keep this in mind for next time. Although, I would prefer to keep using the normal "WP loop" with the normal pagination... | |
Apr 15, 2014 at 18:35 | comment | added | Howdy_McGee♦ | I've seen questions similar to this before, @G.M. has a good answer, but you must show all results on the same page, so if that doens't work for you, then you either show only posts with the meta_key or posts without the meta_key, not both. Here's the post I'm referring to. | |
Apr 15, 2014 at 18:31 | comment | added | powerbuoy | @Howdy_McGee that is correct. Some of my custom post types HAVE this value set. Some don't. And the built in post types (like POST and PAGE) do not. So whenever I try to sort on that custom field only posts WITH the custom field show up. | |
Apr 15, 2014 at 18:20 | comment | added | Howdy_McGee♦ | To clarify, are you wanting to include posts both with a certain metavalue and posts that do not have that metavalue set? | |
Apr 15, 2014 at 18:17 | answer | added | Scruffy Paws | timeline score: 0 | |
Aug 22, 2013 at 22:58 | answer | added | Jon | timeline score: 0 | |
Aug 22, 2013 at 18:06 | answer | added | Rafael M31 | timeline score: 2 | |
Jun 10, 2013 at 2:00 | history | tweeted | twitter.com/#!/StackWordPress/status/343910627284221952 | ||
Jun 10, 2013 at 1:38 | history | edited | powerbuoy | CC BY-SA 3.0 |
added 413 characters in body
|
Jun 10, 2013 at 1:32 | history | edited | powerbuoy | CC BY-SA 3.0 |
added 413 characters in body
|
Jun 10, 2013 at 1:29 | comment | added | powerbuoy |
Also, the actual sorting works fine. The only problem is that posts (or custom post types) without the meta value aren't displayed. (In regards to meta_value_num )
|
|
Jun 10, 2013 at 1:06 | comment | added | powerbuoy |
Thanks for your help, I will try this and get back to you. The reason for ASC DESC is so that it sorts on the meta_value in ASC and the date in DESC , as far as I can tell it works.
|
|
Jun 10, 2013 at 0:43 | comment | added | kaiser |
And make sure that your meta_value_num entries are real numbers. Seen it too often that someone states that it's a number, but in fact saving it as a string in the database.
|
|
Jun 10, 2013 at 0:42 | comment | added | kaiser |
First: meta_query and tax_query are always an array( array() ) as they combine multiple arrays. Second - as mentioned in my answer - you need to use meta_value_num for numbers. It might as well be needed to actually define the meta_value_num (see WP_Query -Codex page entry). Last, it doesn't make sense to order in ASC and DESC direction. That's not possible. The space delimiter only works for orderby and you can't tell it to sort the first ASC and the second DESC . That's what posts_clauses filter is for.
|
|
Jun 10, 2013 at 0:05 | history | edited | powerbuoy | CC BY-SA 3.0 |
added 465 characters in body
|
Jun 9, 2013 at 23:38 | answer | added | kaiser | timeline score: 0 | |
Jun 9, 2013 at 23:24 | comment | added | kaiser | Please show us your code. Makes it easier to answer. | |
Jun 9, 2013 at 22:50 | history | edited | powerbuoy | CC BY-SA 3.0 |
added 209 characters in body
|
Jun 9, 2013 at 22:34 | history | asked | powerbuoy | CC BY-SA 3.0 |