Order by meta_key doesn’t work

Current Query $args = array( ‘post_type’ => ‘brands’, ‘meta_query’ => array( array( ‘key’ => ‘br_type’, ‘value’ => ‘Aviation’ ), array( ‘key’ => ‘br_category’ ), array( ‘key’ => ‘br_name’ ) ), ‘posts_per_page’ => -1, ‘orderby’ => [ ‘br_category’ => ‘ASC’, ‘br_name’ => ‘ASC’ ], ‘order’ => ‘ASC’, ‘fields’ => ‘ids’ ); produce this SQL query ‘SELECT … Read more

Extend meta query arguments

Try this $args = array( ‘post_type’ => ‘events’, ‘meta_query’ => array( ‘relation’ => ‘AND’, array( ‘key’ => ‘fl_type’, ‘value’ => ‘Awards’ ), array( ‘key’ => ‘fl_expire’, ‘value’ => 0, ‘type’ => ‘NUMERIC’, ), array( ‘key’ => ‘fl_global’, ‘value’ => 1, ‘type’ => ‘NUMERIC’, ), ), ‘posts_per_page’ => -1, ‘meta_key’ => ‘fl_order’, ‘orderby’ => ‘meta_value_num’, ‘order’ … Read more

meta query based on month regardless of year

While the regexp solution will function, it quickly gets slower as the number of users increases. This is because the database cannot perform optimisation and indexing tricks, and forces a full table scan. The more users, and the more meta, the greater the cost of the query. At a minimum it requires caching to avoid … Read more

Is this meta query problematic?

Short answer is: Big Meta Queries are incredibly bad and can quickly lead to the MySQL-Server not responding anymore. You should try to rework the meta_query to not have so many clauses. Long Answer: Wordpress Post Metadata is stored incredibly inefficient when it comes to querying. Best advise would be to never ever EVER store … Read more

ACF: How to get users with a ACF flexible content subfield with a specific value AND layout?

New answer I now have a better understanding of the question thanks to OPs comment and have come up with the following. Not tested! global $wpdb; /** * @var string $field The flexible content field name. */ $field = ‘a_flexible_content_field’; /** * @var string $layout The flexible layout name. */ $layout=”layoutTwo”; /** * @var string … Read more