Forums

wp 3.1, metaquery and pre-get-posts. (3 posts)

  1. anmari
    Member
    Posted 1 year ago #

    Just realised that I added to a resolved post, so it is probably not going to get any attention!

    I am just wondering whether this is a bug, or whether I am just not seing something:

    Re http://core.trac.wordpress.org/ticket/16742

    am I understanding the ticket correctly?

    In 3.1 and above I have

    $metaq = ( array
    (array(
    'key' => '_VEVENT',
    'value' => '1',
    'type' => 'string',
    'compare' => '='
    )
    )
    );
    $query->set('meta-query', $metaq );

    and it does not work - all posts shown.

    for < 3.1 I have the

    $query->set('meta_key', '_VEVENT');
    $query->set('meta_value', '1');

    and that works.

    If I use the meta_key (< 3.1 code) in 3.1, that also does not work - all posts shown again.

    So we have lost functionality in 3.1 ? for now ?

    I should add that this is when trying to modify the query that list events in the edit posts menu, using 'pre_get_posts' filter.

    I am pretty sure that the meta query was/is working in when generating own custom query of events, and also weird that it works in lower version.

    Not a train smash for me in my plugin as people also have option to use custom post types as events or to allocate a category as the "event" category and of course those all work nicely.

    I am just trying to satisfy someone who wanted standard posts as events BUT NOT limited to a particular category, and of course would like to educate myself if I am missing something here.

  2. anmari
    Member
    Posted 1 year ago #

    okay, scratch this - I went back and forth and round in circles, I think the net answer is:

    pre 3.1 => meta_key now works

    3.1 => use meta_query

    post 3.1 (3.2 bleeding) => either will work, but meta_query returns a duplicate final post

  3. anmari
    Member
    Posted 1 year ago #

    Oh and adding the meta_key as well as the meta_query fixes the duplicate problem

    See

    http://core.trac.wordpress.org/ticket/15031

Topic Closed

This topic has been closed to new replies.

About this Topic