I need to get posts with a price less than or equal to for example '1000'. The price is set in an arbitrary custom field. Trying to posts a price that is less than or equal to 1000
$posts = new WP_Query( {
'post_type' => 'post',
'meta_query' => array(
'key' => 'price',
'compare' => '<=',
'value' => 1000
),
} );
Expect to get posts with price 1000, 999, 998, etc.
The problem is that many posts have already been created, in which the price is set in such a way that the word for example "from 1000" is added at the beginning. And some are simply given the number 1000. 'value' is compared to the number in which there is a string and the result is not correct.
Is there any way to get the posts right? Or do I need to remove lines from custom fields price?