Forums › Forums › Search & Filter Pro › Hide posts if nothing found
- This topic has 30 replies, 3 voices, and was last updated 6 years, 6 months ago by Ross.
-
Anonymous(Private) March 31, 2018 at 10:49 am #169305
I have tried, it’s not working. Maybe there is a mistake? I although don’t see any possibility in admin-panel to add relation ‘or’ to meta_query.
function add_query_args($query_args, $sfid) { if ($sfid == 218) { date_default_timezone_set('Europe/Kiev'); $now = date('Y-m-d H:i:s'); $query_args = array( 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'event-date-time-start', 'compare' => '>=', 'value' => $now, 'type' => 'DATETIME', ), array( 'key' => 'event-date-time-finish', 'compare' => '>=', 'value' => $now, 'type' => 'DATETIME', ), ), ); } return $query_args; } add_filter('sf_edit_query_args', 'add_query_args', 20, 2);
Ross Moderator(Private) April 3, 2018 at 7:07 pm #169717Hi there, Trevor has asked me to take a look at this.
In regards to post meta relation, do you mean this is not working when using our filter
sf_edit_query_args
?We actually pass those arguments, to a
new WP_Query
– https://codex.wordpress.org/Class_Reference/WP_QueryWhy not try creating your own custom
new WP_Query
(to make sure your date meta query works as expected first), and then try to apply that to the S&F query using our filter?Thanks
Anonymous(Private) April 14, 2018 at 8:58 am #172216Hello, of course I have checked my wp_query out of the plugin. It works correctly. Can you look at my example and check for mistakes or better get me a real example how can I update plugins wp_query args with my meta_query with relation ‘or’ and datetime type. Thanks
-
AuthorPosts