{"id":6814986,"date":"2015-12-04T21:53:10","date_gmt":"2015-12-04T21:53:10","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/filter-events-list-problem\/"},"modified":"2016-08-30T20:59:02","modified_gmt":"2016-08-30T20:59:02","slug":"filter-events-list-problem","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/filter-events-list-problem\/","title":{"rendered":"Filter Events List problem"},"content":{"rendered":"<p>Hi everyone,<\/p>\n<p>I tried to use filter today-tomorrow but it doesn&#8217;t work even if I use it directly \ud83d\ude41 &#8230;<br \/>\nI would like to start from that filter to implement a filter by a single date passed from datepicker, more complex&#8230;why this is not working? This should filter for today ( even is just implemented from authors, I would like to understand how to use the filter manually )<\/p>\n<pre><code>add_filter( &#039;em_events_build_sql_conditions&#039;, &#039;my_em_scope_conditions&#039;,1,2);\nfunction my_em_scope_conditions($conditions, $args){\n\tif( !empty($args[&#039;scope&#039;]) &amp;&amp; $args[&#039;scope&#039;]==&#039;my_custom_date&#039; ){\n\t\t$start_date = date(&#039;Y-m-d&#039;, current_time(&#039;timestamp&#039;));\n\t\t$end_date = date(&#039;Y-m-d&#039;, current_time(&#039;timestamp&#039;));\n\t\t$conditions[&#039;scope&#039;] = &quot; (event_start_date BETWEEN CAST(&#039;$start_date&#039; AS DATE) AND CAST(&#039;$end_date&#039; AS DATE)) OR (event_end_date BETWEEN CAST(&#039;$end_date&#039; AS DATE) AND CAST(&#039;$start_date&#039; AS DATE))&quot;;\n\t}\n\treturn $conditions;\n}\n\nadd_filter( &#039;em_get_scopes&#039;,&#039;my_em_scopes&#039;,1,1);\nfunction my_em_scopes($scopes){\n\t$my_scopes = array(\n\t\t&#039;my_custom_date&#039; =&gt; &#039;My custom date&#039;\n\t);\n\treturn $scopes + $my_scopes;\n}<\/code><\/pre>\n<p>https:\/\/wordpress.org\/plugins\/events-manager\/<\/p>\n","protected":false},"template":"","class_list":["post-6814986","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/6814986","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/6814986\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=6814986"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}