{"id":957023,"date":"2015-04-21T07:18:27","date_gmt":"2015-04-21T14:18:27","guid":{"rendered":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/order-by-end-date-2\/"},"modified":"2015-04-23T08:59:48","modified_gmt":"2015-04-23T15:59:48","slug":"order-by-end-date-2","status":"closed","type":"topic","link":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/order-by-end-date-2\/","title":{"rendered":"Order by End Date"},"content":{"rendered":"<p>I still haven&#8217;t found a solution to being able to order the events archive by end date, I have used meta_value and meta_key but it orders it like a string rather than an integer. I then used meta_value_num but to no success.<\/p>\n<p>Any advice on how to get this to work?<\/p>\n<p>See my previous thread:<\/p>\n<blockquote>\n<p>philipfarmer<br \/>\nApril 20, 2015| Permalink<br \/>\nHi I am looking to order by events by end-date. I have read a number of posts that reference tribe_events_query_posts_orderby, but I can\u2019t find this in the technical documentation to see the structure of this hook.<br \/>\nI have also read up on using the wp pre_get_posts. This is what I have implemented:<\/p>\n<p>function event_title_sort($query) {<br \/>\n    if ( !is_admin() &amp;&amp; ( $query-&gt;tribe_is_event || $query-&gt;tribe_is_event_category ) ) {<br \/>\n        $query-&gt;set( &#8216;meta_key&#8217;,&#8217;EventEndDate&#8217; );<br \/>\n        $query-&gt;set( &#8216;orderby&#8217;,&#8217;meta_value_num&#8217; );<br \/>\n    }<br \/>\n}<br \/>\nadd_action( &#8216;pre_get_posts&#8217;, &#8216;event_title_sort&#8217;, 100, 1 );<br \/>\nThis seems to order the posts by end date but it seems to be ordering it by meta_value (1,12,2,3,34,9) rather than meta_value_num (1,2,3,9,12,34), it also changes the start date to match the end date (this change is only to the text appearing not the actual event start date)<\/p>\n<p>Any suggestions or solutions would be much appreciated.<br \/>\nThanks.<\/p>\n<p>Posts: 4514<br \/>\nBrian<br \/>\nApril 20, 2015| Permalink<br \/>\nHi,<br \/>\nThanks for using our plugin.<br \/>\nThe plugin is designed to order events by the start date and time so changing this could be tricky and create unintended issues.<br \/>\nHowever, we use a couple different ones for order:<br \/>\nmeta_value<br \/>\nmeta_key<br \/>\nDo either of those work?<\/p>\n<p>Posts: 4<br \/>\nTopics: 3<br \/>\nphilipfarmer<br \/>\nApril 21, 2015| Permalink<br \/>\nHi Brian,<br \/>\nThanks for the quick response. No worries I understand any help would be much appreciated.<br \/>\nAs I previously stated I have used both those. They seemed to order the events 1,12,3,9 rather than 1,3,9,12. So I tried meta_value_num to solve this issue but it remains the same.<br \/>\nAs a test I tried these to order the events by title and it worked fine, the issue seems to be that I am dealing with numbers.<br \/>\nCheers<\/p>\n<p>Posts: 4514<br \/>\nBrian<br \/>\nApril 21, 2015| Permalink<br \/>\nOk thanks for the information. Glad you are able to move forward on your customization.<br \/>\nSince there is nothing more we can do here on a customization I am closing out this ticket, but if you have any other issues related to this or something new, please create a new one.<br \/>\nThanks<\/p>\n<\/blockquote>\n","protected":false},"template":"","class_list":["post-957023","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>Order by End Date -<\/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\/order-by-end-date-2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Order by End Date -\" \/>\n<meta property=\"og:description\" content=\"I still haven&#8217;t found a solution to being able to order the events archive by end date, I have used meta_value and meta_key but it orders it like a string rather than an integer. I then used meta_value_num but to no success. Any advice on how to get this to work? See my previous thread: [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/order-by-end-date-2\/\" \/>\n<meta property=\"article:modified_time\" content=\"2015-04-23T15:59:48+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=\"2 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\/order-by-end-date-2\/\",\"url\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/order-by-end-date-2\/\",\"name\":\"Order by End Date -\",\"isPartOf\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\"},\"datePublished\":\"2015-04-21T14:18:27+00:00\",\"dateModified\":\"2015-04-23T15:59:48+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/order-by-end-date-2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/order-by-end-date-2\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/order-by-end-date-2\/#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\":\"Order by End Date\"}]},{\"@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":"Order by End Date -","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\/order-by-end-date-2\/","og_locale":"en_US","og_type":"article","og_title":"Order by End Date -","og_description":"I still haven&#8217;t found a solution to being able to order the events archive by end date, I have used meta_value and meta_key but it orders it like a string rather than an integer. I then used meta_value_num but to no success. Any advice on how to get this to work? See my previous thread: [&hellip;]","og_url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/order-by-end-date-2\/","article_modified_time":"2015-04-23T15:59:48+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/order-by-end-date-2\/","url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/order-by-end-date-2\/","name":"Order by End Date -","isPartOf":{"@id":"https:\/\/theeventscalendar.com\/support\/#website"},"datePublished":"2015-04-21T14:18:27+00:00","dateModified":"2015-04-23T15:59:48+00:00","breadcrumb":{"@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/order-by-end-date-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/theeventscalendar.com\/support\/forums\/topic\/order-by-end-date-2\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/order-by-end-date-2\/#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":"Order by End Date"}]},{"@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\/957023","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\/957023\/revisions"}],"predecessor-version":[{"id":957055,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/957023\/revisions\/957055"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/media?parent=957023"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}