Order by custom field date?

There are similar posts on this site about the same topic, if you look around. But here is your answer: To make this work you need to change your date format. You can sort alphabetically, or numerically, not calender-merically. The only human date format that orders correctly is YYYY/MM/DD. The separator are optional and shouldn’t … Read more

WordPress Search documentation: how to improve search query using taxonomy terms, custom meta fields?

I had the same question a couple of weeks ago. Here’s what I did to make it work for me. How Do I Use WP_Query to Run This Database Query as Search Result? If you’ll read through my answer that I posted for reference’s sake, you’ll see that I ended up adding a filter add_filter(‘post_request’,’your_function_name’); … Read more

WP REST API: Order posts by meta value (acf)?

I’m guessing you haven’t exposed meta_key and meta_value to the REST API with the rest_query_vars filter, so this should do it: function my_add_meta_vars ($current_vars) { $current_vars = array_merge ($current_vars, array (‘meta_key’, ‘meta_value’)); return $current_vars; } add_filter (‘rest_query_vars’, ‘my_add_meta_vars’); Then you can refer to meta_key and meta_value in your query. Be aware that this obviously exposes … Read more