{"id":1896498,"date":"2019-10-18T13:19:16","date_gmt":"2019-10-18T17:19:16","guid":{"rendered":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/order-events-in-main-blog-loop-by-post-date-2\/"},"modified":"2025-03-05T11:45:02","modified_gmt":"2025-03-05T16:45:02","slug":"order-events-in-main-blog-loop-by-post-date","status":"publish","type":"post","link":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/order-events-in-main-blog-loop-by-post-date\/","title":{"rendered":"Order Events by Post Date in the Main WordPress Post Query"},"content":{"rendered":"\n<p class=\"p1\">Under <strong>Events > Settings > General > Viewing,<\/strong> you can set your events to show alongside your posts in the main blog loop on your site by clicking on &#8220;Include events in main blog loop&#8221; setting. By default, the events are ordered by the event date. This snippet allows you to change that, so events in the main blog loop are ordered by the date they were published.<\/p>\n\n\n\n<p>To do this, paste the following in your theme&#8217;s functions.php file.&nbsp;Please note that you may need to clear your cache to see the changes. If you need help using this snippet, feel free to post to our help desk.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\nadd_action( &#039;pre_get_posts&#039;, &#039;tribe_post_date_ordering&#039;, 51 );\n\nfunction tribe_post_date_ordering( $query ) {\n\tif ( ! empty( $query-&gt;tribe_is_multi_posttype ) ) {\n\t\tremove_filter( &#039;posts_fields&#039;, array( &#039;Tribe__Events__Query&#039;, &#039;multi_type_posts_fields&#039; ) );\n\t\t$query-&gt;set( &#039;order&#039;, &#039;DESC&#039; );\n\t}\n}\n<\/pre><\/div>\n\n\n<p class=\"has-background\" style=\"background-color:var(--global-palette8)\"><strong>Note:<\/strong> This snippet will only work correctly if the following setting is <em>unchecked<\/em> <strong>Events &gt; Settings &gt; General &gt; Condense Events in Series<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Under Events > Settings > General > Viewing, you can set your events to show alongside your posts in the main blog loop on your site by clicking on &#8220;Include events in main blog loop&#8221; setting. By default, the events are ordered by the event date. This snippet allows you to change that, so events&#8230;<\/p>\n","protected":false},"author":3,"featured_media":1955565,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_kad_blocks_custom_css":"","_kad_blocks_head_custom_js":"","_kad_blocks_body_custom_js":"","_kad_blocks_footer_custom_js":"","_swpsp_post_exclude":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"ep_exclude_from_search":false,"footnotes":""},"categories":[79],"tags":[25,58],"stellar-product-taxonomy":[161],"class_list":["post-1896498","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-snippets","tag-customizations","tag-php","stellar-product-taxonomy-the-events-calendar"],"acf":[],"taxonomy_info":{"category":[{"value":79,"label":"Snippets"}],"post_tag":[{"value":25,"label":"Customizations"},{"value":58,"label":"PHP"}],"stellar-product-taxonomy":[{"value":161,"label":"The Events Calendar"}]},"featured_image_src_large":["https:\/\/images.theeventscalendar.com\/kb\/uploads\/2023\/02\/social-share-1024x538.png",1024,538,true],"author_info":{"display_name":"Jaime Marchwinski","author_link":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/author\/jaimetri-be\/"},"comment_info":0,"category_info":[{"term_id":79,"name":"Snippets","slug":"snippets","term_group":0,"term_taxonomy_id":79,"taxonomy":"category","description":"","parent":0,"count":136,"filter":"raw","term_order":"0","cat_ID":79,"category_count":136,"category_description":"","cat_name":"Snippets","category_nicename":"snippets","category_parent":0}],"tag_info":[{"term_id":25,"name":"Customizations","slug":"customizations","term_group":0,"term_taxonomy_id":25,"taxonomy":"post_tag","description":"","parent":0,"count":177,"filter":"raw","term_order":"0"},{"term_id":58,"name":"PHP","slug":"php","term_group":0,"term_taxonomy_id":58,"taxonomy":"post_tag","description":"","parent":20,"count":128,"filter":"raw","term_order":"0"}],"_links":{"self":[{"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1896498","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/comments?post=1896498"}],"version-history":[{"count":2,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1896498\/revisions"}],"predecessor-version":[{"id":1964501,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1896498\/revisions\/1964501"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/media\/1955565"}],"wp:attachment":[{"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/media?parent=1896498"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/categories?post=1896498"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/tags?post=1896498"},{"taxonomy":"stellar-product-taxonomy","embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/stellar-product-taxonomy?post=1896498"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}