I have made a custom post type Named Team. In this custom post, there are many custom fields for a single team. Now, I am creating a shortcode which will show the posts based on two factor.
1. Points – Point of the teams
2. NRR – Net run rate of the team.

First condition is that the team with highest point should be fetched first. This is going well till two teams appear with same point (say 10 points for both). Now, if this situation arises; NRR is compared next and the team having highest NRR gets to rank first.

I am using following arguments for WP_Query

$args = array (
      'orderby'   => 'meta_value_num',
      'meta_key'  => 'pts'       

Thanks in Advance

Read more here: Sort a custom Post using two custom fields based on if else condition


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: