Site icon Hip-Hop Website Design and Development

Is meta_key used for ordering, filtering, or both?

In testing I am getting inconsistent results when experimenting with the meta_key parameter on a fresh WordPress install. I’m combining it with orderby and/or meta_value to understand ordering and filtering results.

Is the meta_key parameter used for ordering search results as mentioned here or is it used for filtering as mentioned here? In no case have I seen WordPress use it for both features, but it would apply to one or the other inconsistently.

I am aware that I could filter by meta_query but that is not the scope of this question. I have examined the WP_Query->get_posts() method, and I see the exact steps used to construct the SQL (convoluted as it is) but the purpose of this question is to understand the intended behaviour and submit a patch if necessary.

I am testing using WordPress version 4.9.1 (current up-to-date version), but I’m interested in all WordPress 4.x versions and differences between them.