• Hello everyone,

    As I said before in this topic, I was having trouble using ‘2012-02-01,2012-02-28’ scope with WP_Query (I’m not using WP_Event class for particular reasons, as mentioned at the linked topic above).

    I realized that the code implemented at classes/em-object.php to handle this kind of scope wasn’t implemented at classes/em-event-post.php. It checks for an array inside $scope and add the range conditional [classes/em-object.php line 199]. To make it work using WP_Query I adapted the code inside em-object.php to work inside em-event-post.php.

    The sample is here:
    https://pastebin.com/YwErsi76 (starting from line 157 and changing the first if to elseif)

    Now I’m able to use this query:

    $args = array( 'post_type' => 'event', 'scope' => array('2012-02-01','2012-02-28'));
    query_posts($args);

    Please, feel free to adapt and comment.

Viewing 3 replies - 1 through 3 (of 3 total)
  • thanks for sharing, however maybe you can try to use hooks/filters to make it update friendly.

    you may want to check the dev version in the EM_Object function, I now have a build_wp_query_conditions function which is still experimental, but in theory you could create a WP_Query class and use the above to create the right query vars.

    I believe this already allows for what you added

    thanks for contributing!

    btw, if you do play with it, pls let me know your findings, I haven’t tried it yet…

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: Events Manager] Code for custom date range scope with WP_Query’ is closed to new replies.