{"id":235783,"date":"2014-06-19T10:32:56","date_gmt":"2014-06-19T17:32:56","guid":{"rendered":"http:\/\/tri.be\/support\/forums\/topic\/orderby-question-with-a-twist\/"},"modified":"2014-09-04T20:31:26","modified_gmt":"2014-09-05T03:31:26","slug":"orderby-question-with-a-twist","status":"closed","type":"topic","link":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/orderby-question-with-a-twist\/","title":{"rendered":"Orderby question, with a twist&#8230;"},"content":{"rendered":"<p>I am trying to achieve a display of events, ordered by start date, starting with the current date. I have looked at the following forum topic (https:\/\/theeventscalendar.com\/support\/forums\/topic\/wp_query-events-with-date-year-filter\/), but am not sure if I know how to apply it to an element. The theme is Enfold and their full-width-masonry layout element. It is a wonderful way to display upcoming events, if I could just get the ordering down. I managed to get it to allow sorting, but I only have a handful of sorting options. Here is the code I used to add the ordering ability to the admin. The code works in that I can order by various fields, including post date, but not event_date. <\/p>\n<p>if(!function_exists(&#8216;avia_custom_query_extension&#8217;))<br \/>\n{<br \/>\n    function avia_custom_query_extension($query, $params)<br \/>\n    {<br \/>\n        global $avia_config;<br \/>\n        if(!empty($avia_config[&#8216;avia_custom_query_options&#8217;][&#8216;order&#8217;]))<br \/>\n        {<br \/>\n            $query[&#8216;order&#8217;] = $avia_config[&#8216;avia_custom_query_options&#8217;][&#8216;order&#8217;];<br \/>\n        }<\/p>\n<p>        if(!empty($avia_config[&#8216;avia_custom_query_options&#8217;][&#8216;orderby&#8217;]))<br \/>\n        {<br \/>\n            $query[&#8216;orderby&#8217;] = $avia_config[&#8216;avia_custom_query_options&#8217;][&#8216;orderby&#8217;];<br \/>\n        }<\/p>\n<p>        unset($avia_config[&#8216;avia_custom_query_options&#8217;]);<\/p>\n<p>        return $query;<br \/>\n    }<\/p>\n<p>    add_filter(&#8216;avia_masonry_entries_query&#8217;, &#8216;avia_custom_query_extension&#8217;, 10, 2);<br \/>\n    add_filter(&#8216;avia_post_grid_query&#8217;, &#8216;avia_custom_query_extension&#8217;, 10, 2);<br \/>\n    add_filter(&#8216;avia_post_slide_query&#8217;, &#8216;avia_custom_query_extension&#8217;, 10, 2);<br \/>\n    add_filter(&#8216;avia_blog_post_query&#8217;, &#8216;avia_custom_query_extension&#8217;, 10, 2);<\/p>\n<p>    add_filter(&#8216;avf_template_builder_shortcode_elements&#8217;,&#8217;avia_custom_query_options&#8217;, 10, 1);<br \/>\n    function avia_custom_query_options($elements)<br \/>\n    {<br \/>\n        $allowed_elements = array(&#8216;av_blog&#8217;,&#8217;av_masonry_entries&#8217;,&#8217;av_postslider&#8217;,&#8217;av_portfolio&#8217;);<\/p>\n<p>        if(isset($_POST[&#8216;params&#8217;][&#8216;allowed&#8217;]) &amp;&amp; in_array($_POST[&#8216;params&#8217;][&#8216;allowed&#8217;], $allowed_elements))<br \/>\n        {<br \/>\n            $elements[] = array(<br \/>\n                &#8220;name&#8221; =&gt; __(&#8220;Custom Query Orderby&#8221;,&#8217;avia_framework&#8217; ),<br \/>\n                &#8220;desc&#8221; =&gt; __(&#8220;Set a custom query orderby value&#8221;,&#8217;avia_framework&#8217; ),<br \/>\n                &#8220;id&#8221;   =&gt; &#8220;orderby&#8221;,<br \/>\n                &#8220;type&#8221; \t=&gt; &#8220;select&#8221;,<br \/>\n                &#8220;std&#8221; \t=&gt; &#8220;&#8221;,<br \/>\n                &#8220;subtype&#8221; =&gt; array(<br \/>\n                    __(&#8216;Default Order&#8217;,  &#8216;avia_framework&#8217; ) =&gt;&#8221;,<br \/>\n                    __(&#8216;Title&#8217;,  &#8216;avia_framework&#8217; ) =&gt;&#8217;title&#8217;,<br \/>\n                    __(&#8216;Random&#8217;,  &#8216;avia_framework&#8217; ) =&gt;&#8217;rand&#8217;,<br \/>\n                    __(&#8216;Date&#8217;,  &#8216;avia_framework&#8217; ) =&gt;&#8217;date&#8217;,<br \/>\n                    __(&#8216;Author&#8217;,  &#8216;avia_framework&#8217; ) =&gt;&#8217;author&#8217;,<br \/>\n                    __(&#8216;Name (Post Slug)&#8217;,  &#8216;avia_framework&#8217; ) =&gt;&#8217;name&#8217;,<br \/>\n                    __(&#8216;Modified&#8217;,  &#8216;avia_framework&#8217; ) =&gt;&#8217;modified&#8217;,<br \/>\n                    __(&#8216;Comment Count&#8217;,  &#8216;avia_framework&#8217; ) =&gt;&#8217;comment_count&#8217;,<br \/>\n                    __(&#8216;Page Order&#8217;,  &#8216;avia_framework&#8217; ) =&gt;&#8217;menu_order&#8217;)<br \/>\n            );<\/p>\n<p>            $elements[] = array(<br \/>\n                &#8220;name&#8221; =&gt; __(&#8220;Custom Query Order&#8221;,&#8217;avia_framework&#8217; ),<br \/>\n                &#8220;desc&#8221; =&gt; __(&#8220;Set a custom query order&#8221;,&#8217;avia_framework&#8217; ),<br \/>\n                &#8220;id&#8221;   =&gt; &#8220;order&#8221;,<br \/>\n                &#8220;type&#8221; \t=&gt; &#8220;select&#8221;,<br \/>\n                &#8220;std&#8221; \t=&gt; &#8220;&#8221;,<br \/>\n                &#8220;subtype&#8221; =&gt; array(<br \/>\n                    __(&#8216;Default Order&#8217;,  &#8216;avia_framework&#8217; ) =&gt;&#8221;,<br \/>\n                    __(&#8216;Ascending Order&#8217;,  &#8216;avia_framework&#8217; ) =&gt;&#8217;ASC&#8217;,<br \/>\n                    __(&#8216;Descending Order&#8217;,  &#8216;avia_framework&#8217; ) =&gt;&#8217;DESC&#8217;));<br \/>\n        }<\/p>\n<p>        return $elements;<br \/>\n    }<\/p>\n<p>    add_filter(&#8216;avf_template_builder_shortcode_meta&#8217;, &#8216;avia_custom_query_add_query_params_to_config&#8217;, 10, 4);<br \/>\n    function avia_custom_query_add_query_params_to_config($meta, $atts, $content, $shortcodename)<br \/>\n    {<br \/>\n        global $avia_config;<br \/>\n        if(empty($avia_config[&#8216;avia_custom_query_options&#8217;])) $avia_config[&#8216;avia_custom_query_options&#8217;] = array();<\/p>\n<p>        if(!empty($atts[&#8216;order&#8217;]))<br \/>\n        {<br \/>\n            $avia_config[&#8216;avia_custom_query_options&#8217;][&#8216;order&#8217;] = $atts[&#8216;order&#8217;];<br \/>\n        }<\/p>\n<p>        if(!empty($atts[&#8216;orderby&#8217;]))<br \/>\n        {<br \/>\n            $avia_config[&#8216;avia_custom_query_options&#8217;][&#8216;orderby&#8217;] = $atts[&#8216;orderby&#8217;];<br \/>\n        }<\/p>\n<p>        return $meta;<br \/>\n    }<br \/>\n}<\/p>\n<p>I have reached out to Kriesi and they responded with the following:<\/p>\n<p>Hi solarmediapro!<br \/>\nI\u2019m sorry but \u201cevent date\u201d is not a default wordpress orderby\/order parameter: http:\/\/codex.wordpress.org\/Class_Reference\/WP_Query#Order_.26_Orderby_Parameters \u2013 and probably it require some additional tweaking and code customization to query the events based on the \u201cevent date\u201d. I suggest to contact the plugin author \u2013 maybe they can provide some custom code for free and if not please hire a freelancer who can implement the event date query option.<br \/>\nBest regards,<br \/>\nPeter<\/p>\n<p>***<\/p>\n<p>Can you help me figure this out? I honestly am not sure what direction to go, but know that it really should be possible. Is it not the expected that post date and event dates would be separate for obvious reasons, and that one might want to sort and filter by dates?<\/p>\n<p>I would be happy to share access with the site, so you could see the back-end as well.<\/p>\n","protected":false},"template":"","class_list":["post-235783","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>Orderby question, with a twist... -<\/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\/orderby-question-with-a-twist\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Orderby question, with a twist... -\" \/>\n<meta property=\"og:description\" content=\"I am trying to achieve a display of events, ordered by start date, starting with the current date. I have looked at the following forum topic (https:\/\/theeventscalendar.com\/support\/forums\/topic\/wp_query-events-with-date-year-filter\/), but am not sure if I know how to apply it to an element. The theme is Enfold and their full-width-masonry layout element. It is a wonderful way [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/orderby-question-with-a-twist\/\" \/>\n<meta property=\"article:modified_time\" content=\"2014-09-05T03:31:26+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=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/orderby-question-with-a-twist\/\",\"url\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/orderby-question-with-a-twist\/\",\"name\":\"Orderby question, with a twist... -\",\"isPartOf\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\"},\"datePublished\":\"2014-06-19T17:32:56+00:00\",\"dateModified\":\"2014-09-05T03:31:26+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/orderby-question-with-a-twist\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/orderby-question-with-a-twist\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/orderby-question-with-a-twist\/#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\":\"Orderby question, with a twist&#8230;\"}]},{\"@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":"Orderby question, with a twist... -","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\/orderby-question-with-a-twist\/","og_locale":"en_US","og_type":"article","og_title":"Orderby question, with a twist... -","og_description":"I am trying to achieve a display of events, ordered by start date, starting with the current date. I have looked at the following forum topic (https:\/\/theeventscalendar.com\/support\/forums\/topic\/wp_query-events-with-date-year-filter\/), but am not sure if I know how to apply it to an element. The theme is Enfold and their full-width-masonry layout element. It is a wonderful way [&hellip;]","og_url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/orderby-question-with-a-twist\/","article_modified_time":"2014-09-05T03:31:26+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/orderby-question-with-a-twist\/","url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/orderby-question-with-a-twist\/","name":"Orderby question, with a twist... -","isPartOf":{"@id":"https:\/\/theeventscalendar.com\/support\/#website"},"datePublished":"2014-06-19T17:32:56+00:00","dateModified":"2014-09-05T03:31:26+00:00","breadcrumb":{"@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/orderby-question-with-a-twist\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/theeventscalendar.com\/support\/forums\/topic\/orderby-question-with-a-twist\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/orderby-question-with-a-twist\/#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":"Orderby question, with a twist&#8230;"}]},{"@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\/235783","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":0,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/235783\/revisions"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/media?parent=235783"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}