Support

Account

Home Forums Front-end Issues Displaying posts using a custom date field Reply To: Displaying posts using a custom date field

  • If the fields are not part of a repeater or some special field type, for example the date fields are just date pickers, number fields are just numbers, there are no checkboxes or multiselect fields that store data in serialized arrays, then you are just sorting by multiple postmeta fields.

    There was a new feature added to WP in 4.2 that allows you to do this. I don’t know if it’s made it into the documentation. This page explains it. https://make.wordpress.org/core/2015/03/30/query-improvements-in-wp-4-2-orderby-and-meta_query/

    And like I said, you need to modify the main query to change the order. This is done using pre_get_posts https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts

    Here is a posts on stack exchange that shows how to use pre_get_posts an order the posts by a single meta value http://wordpress.stackexchange.com/questions/141355/wordpress-screwing-up-orderby-meta-value-num-in-pre-get-posts