{"id":972639,"date":"2015-06-24T09:17:50","date_gmt":"2015-06-24T16:17:50","guid":{"rendered":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/wp_query-filter-by-dayofweek\/"},"modified":"2015-07-09T07:30:06","modified_gmt":"2015-07-09T14:30:06","slug":"wp_query-filter-by-dayofweek","status":"closed","type":"topic","link":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/wp_query-filter-by-dayofweek\/","title":{"rendered":"WP_Query filter by dayofweek"},"content":{"rendered":"<p>Hello,<\/p>\n<p>I am building a custom query using WP_Query for The Events Calendar. I am trying to filter events by a specific day of the week e.g. Display ALL events that are on Mondays. Does anyone happen to know how I can achieve this?<\/p>\n<p>I understand there is a WP_Query date_query function, but this only appears to work for WordPress&#8217;s default post_date column.<\/p>\n<p>Also, if someone knows how to achieve this via tribes default tribe_get_events loop, then please let me know.<\/p>\n<p>Any help is much appreciated!<\/p>\n<p>Current PHP code:<\/p>\n<pre><code>\n\t\t\t\t\t$args = array(\n\t\t\t\t\t\t\/\/&#039;post_type&#039; =&gt; &#039;tribe_events&#039;,\n\t\t\t\t\t\t&#039;post_type&#039;=&gt;array(TribeEvents::POSTTYPE),\n\t\t\t\t\t\t&#039;meta_key&#039;=&gt;&#039;_EventStartDate&#039;,\n\t\t\t\t\t\t&#039;orderby&#039;=&gt;&#039;_EventStartDate&#039;,\n\t\t\t\t\t\t&#039;order&#039;=&gt;&#039;ASC&#039;,\n\t\t\t\t\t\t&#039;posts_per_page&#039; =&gt; 999,\n\t\t\t\t\t\t&#039;meta_query&#039;  =&gt; array(\n\t\t\t\t\t\t                  &#039;key&#039;     =&gt; &#039;_EventStartDate&#039;,\n\t\t\t\t\t\t                  &#039;type&#039;    =&gt; &#039;DATE&#039;\n\t\t\t\t\t\t                ),\n\t\t\t\t\t\t&#039;date_query&#039; =&gt; array()\n\t\t\t\t\t);\n<\/code><\/pre>\n<p>Current Array looks like<\/p>\n<pre><code>(\n    [post_type] =&gt; Array\n        (\n            [0] =&gt; tribe_events\n        )\n\n    [meta_key] =&gt; _EventStartDate\n    [orderby] =&gt; _EventStartDate\n    [order] =&gt; ASC\n    [posts_per_page] =&gt; 999\n    [meta_query] =&gt; Array\n        (\n            [key] =&gt; _EventStartDate\n            [type] =&gt; DATE\n            [date_query] =&gt; Array\n                (\n                    [0] =&gt; Array\n                        (\n                            [dayofweek] =&gt; Array\n                                (\n                                    [0] =&gt; 6\n                                    [1] =&gt; 7\n                                )\n\n                            [compare] =&gt; =\n                        )\n\n                )\n\n        )\n\n    [date_query] =&gt; Array\n        (\n        )\n\n)<\/code><\/pre>\n<p>Thanks,<\/p>\n<p>Nick<\/p>\n","protected":false},"template":"","class_list":["post-972639","topic","type-topic","status-closed","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>WP_Query filter by dayofweek -<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/wp_query-filter-by-dayofweek\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"WP_Query filter by dayofweek -\" \/>\n<meta property=\"og:description\" content=\"Hello, I am building a custom query using WP_Query for The Events Calendar. I am trying to filter events by a specific day of the week e.g. Display ALL events that are on Mondays. Does anyone happen to know how I can achieve this? I understand there is a WP_Query date_query function, but this only [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/wp_query-filter-by-dayofweek\/\" \/>\n<meta property=\"article:modified_time\" content=\"2015-07-09T14:30:06+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/wp_query-filter-by-dayofweek\/\",\"url\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/wp_query-filter-by-dayofweek\/\",\"name\":\"WP_Query filter by dayofweek -\",\"isPartOf\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\"},\"datePublished\":\"2015-06-24T16:17:50+00:00\",\"dateModified\":\"2015-07-09T14:30:06+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/wp_query-filter-by-dayofweek\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/wp_query-filter-by-dayofweek\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/wp_query-filter-by-dayofweek\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/theeventscalendar.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Topics\",\"item\":\"https:\/\/theeventscalendar.com\/support\/topics\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Calendar Products\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Events Calendar PRO\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/events-calendar-pro\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"WP_Query filter by dayofweek\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\",\"url\":\"https:\/\/theeventscalendar.com\/support\/\",\"name\":\"\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"WP_Query filter by dayofweek -","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/wp_query-filter-by-dayofweek\/","og_locale":"en_US","og_type":"article","og_title":"WP_Query filter by dayofweek -","og_description":"Hello, I am building a custom query using WP_Query for The Events Calendar. I am trying to filter events by a specific day of the week e.g. Display ALL events that are on Mondays. Does anyone happen to know how I can achieve this? I understand there is a WP_Query date_query function, but this only [&hellip;]","og_url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/wp_query-filter-by-dayofweek\/","article_modified_time":"2015-07-09T14:30:06+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/wp_query-filter-by-dayofweek\/","url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/wp_query-filter-by-dayofweek\/","name":"WP_Query filter by dayofweek -","isPartOf":{"@id":"https:\/\/theeventscalendar.com\/support\/#website"},"datePublished":"2015-06-24T16:17:50+00:00","dateModified":"2015-07-09T14:30:06+00:00","breadcrumb":{"@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/wp_query-filter-by-dayofweek\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/theeventscalendar.com\/support\/forums\/topic\/wp_query-filter-by-dayofweek\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/wp_query-filter-by-dayofweek\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/theeventscalendar.com\/support\/"},{"@type":"ListItem","position":2,"name":"Topics","item":"https:\/\/theeventscalendar.com\/support\/topics\/"},{"@type":"ListItem","position":3,"name":"Calendar Products","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/"},{"@type":"ListItem","position":4,"name":"Events Calendar PRO","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/events-calendar-pro\/"},{"@type":"ListItem","position":5,"name":"WP_Query filter by dayofweek"}]},{"@type":"WebSite","@id":"https:\/\/theeventscalendar.com\/support\/#website","url":"https:\/\/theeventscalendar.com\/support\/","name":"","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/972639","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":1,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/972639\/revisions"}],"predecessor-version":[{"id":972764,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/972639\/revisions\/972764"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/media?parent=972639"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}