F
F
FreeZa2018-04-21 03:22:23
WordPress
FreeZa, 2018-04-21 03:22:23

WORDPRESS, how to get a post via meta_query with the smallest meta_value?

Good day, I'm bothering with WordPress and, in a word, I'm studying =)
a question arose, I make a request to the database:

$true_args = array(
  'meta_query' => array(
    'relation' => 'AND',
    array(
      'key' => 'user-rating',
      'value' => 'pro'
    ),
    array(
      'key' => 'rating',
      'value' => array( 100, 200 ),
      'type' => 'numeric',
      'compare' => 'BETWEEN'
    )
  )
);
$true_query = new WP_Query( $true_args );

Actually, everything works and perfectly displays what is needed, but I just can’t figure out how to implement such a thing:
(PSEUDOCODE)
$true_args = array(
  'meta_query' => array(
    'relation' => 'AND',
    array(
      'key' => 'user-rating',
      'value' => 'pro'
    ),
    array(
      'key' => 'rating',
      'value' => 'САМОЕ МАЛЕНЬКОЕ ЗНАЧЕНИЕ В БАЗЕ',
      'type' => 'numeric'
    ),
    array(
      'key' => 'rating',
      'value' => 'САМОЕ БОЛЬШОЕ ЗНАЧЕНИЕ В БАЗЕ',
      'type' => 'numeric'
    )
  )
);
$true_query = new WP_Query( $true_args );

Actually, the task is to get a person's profile from the database, the record with the smallest rating (it is not equal to 0) and get the one with the highest rating with the previous filtering condition
. Thank you in advance for useful answers =)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question