[wp-hackers] Using Meta Keys with pre_get_posts ?
scribu
scribu at gmail.com
Thu Apr 15 15:42:43 UTC 2010
On Thu, Apr 15, 2010 at 1:47 PM, Almost George WP-Hackers List <
wp-hackers-list at almostexciting.com> wrote:
> On Thu, Apr 15, 2010 at 2:13 AM, scribu <scribu at gmail.com> wrote:
> > Checking a single meta key value is easy:
> >
> >
> > function check_meta_key($wp_query) {
> > $wp_query->set('meta_key', 'my_key');
> > $wp_query->set('meta_value', 'my_value);
> > }
> > do_action('parse_query', 'check_meta_key');
> >
>
> Thanks! Is it possible to use conditionals, like "less than" or "not
> equal to" here? What might that look like?
>
For that, you'll have to use the 'posts_where' filter.
Take a look at how it's done in the Custom Fields Taxonomies plugin which
supports this:
http://wordpress.org/extend/plugins/custom-field-taxonomies/
--
http://scribu.net
More information about the wp-hackers
mailing list