Select posts using @wordpress/data with query based on custom field always returns all records

It appears that REST API doesn’t support all the meta_query parameters that WP_Query does. Only the basic meta queries with some comparison operators are supported. Therefore we need to make one of workarounds to get what we want: Add some REST API Filter to our theme/plugin add_filter(‘rest_{post_type}_query’, function($args, $request) { $params = $request->get_params(); if(isset($params[‘meta_compare’])) { … Read more

Query ‘orderby’ when there are multiple values for the same meta_key

Sorting by multiple meta keys (ref) may be helpful (untested): add_action( ‘pre_get_posts’, function ( \WP_Query $query ) { $orderby = $query->get( ‘orderby’ ); if ( ‘start_date’ === $orderby || ‘end_date’ === $orderby ) { $meta_query = array( ‘relation’ => ‘OR’, ‘meta_query_1’ => array( ‘key’ => $orderby, // start_date or end_date ), ‘meta_query_2’ => array( ‘key’ … Read more

How to order product for key exists?

The meta_key parameter tells WP_Query to only return posts that have the price_sale_custom meta data. Remove that first, and then change orderby to reference the meta_query values: This is something that WordPress added support for in 4.2: https://make.wordpress.org/core/2015/03/30/query-improvements-in-wp-4-2-orderby-and-meta_query/ https://stackoverflow.com/questions/17745334/how-to-order-by-multiple-meta-keys

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)