Timeline for meta_query compare='!=' with multiple custom fields
Current License: CC BY-SA 3.0
4 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Mar 7, 2014 at 18:37 | comment | added | gmazzap |
@Etienne essentially my answer is just an extension of @elleeott's code too. The problems I see there are: (1) little flexibility (2) the fact that to use template tags (the_title and such) for retrieved posts you have to setup_postdata($post) or apply_filters everytime (3) possible issues with some plugins, in fact what you get are raw objects, where WP_Query returns WP_Posts objects (3) last, but not least, using that code you retrieve all the posts that have no 'my_custom_field' at all, where WP_Query with 'meta_query' doesn't work like so.
|
|
Mar 7, 2014 at 18:19 | comment | added | etiennedi | Thanks a lot for your comprehensive answer. This is indeed the most flexible approach. In this case I've already implemented @elleeott 's code and extended it by a couple other WHERE clauses to exclude unpublished posts, etc. Works perfectly for this situation. I will keep your solution in mind, I'm pretty sure I might use it in the future. Thanks a lot. I will also definitely look into custom taxonomy. I'll upvote as soon as I have the required reputation. | |
Mar 7, 2014 at 18:10 | history | edited | gmazzap | CC BY-SA 3.0 |
added 130 characters in body
|
Mar 7, 2014 at 17:54 | history | answered | gmazzap | CC BY-SA 3.0 |