At the moment i have a custom field named “price” to order my posts correctly.
The following already works:
$query_args['meta_key'] = 'price';
$query_args['orderby'] = 'meta_value_num';
$query_args['order'] = 'asc';
The problem is that this is a “recommended” price, the real price needs to be calculated inside the loop.
The question is to know if there is a way or a trick, where we can run the loop, calculate the real price and show the posts based on the real price variable.
At the moment you publish/update the post with recommended
price
, it’s better to have another custom meta post to save thereal price
in it by using add_action() and add_post_meta(), then you can use the query you posted but with$query_args['meta_key'] = 'real_price';
Something like below: