How to order posts by two meta values

level Advanced

How to order posts by two meta values
level Advanced

By default, WordPress allows you to sort results of a query by one meta value, but what if you need to sort results by two meta values (For example date and time)? Here ‘s a working example.

Paste the code below in your template file where you need to sort the results of the query.

Please note that this query is given as an example and might need to be adapted to fit your specific needs.