I have a post with three meta-fields.
add_post_meta($my_post, 'times', $times);
And i would like to query this category and sort the posts by the meta field value of one of them.
The args i use right now are:
$args=array( 'post_type' => 'post', 'category_name' => 'players', 'order' => 'DESC', 'orderby' => 'meta_value_num', 'meta_key' => 'times', 'meta_query' => array( array( 'key' => 'times', 'value' => 0, 'compare' => '>=', ), 'posts_per_page'=> '8' ) );
Where times is the name of the metafield.The above code isn’t returning anything.
You have
'posts_per_page'=> '8'
inside yourmeta_query
argument.Change your code into the following: