arrays - Wordpress Sum meta_values from posts and order them per category -


I am using this code to query all the categories from an array and add values ​​of meta sqqs per square :

   gt; $ cat, 'meta_key' = & gt; 'proyecto_votos',' post_type '= & gt;' proyecto ',' posts_per_page '=> 1'); $ The_query = New WP_Query ($ Args); While ($ the_query-> is_pause ()): $ the_query-> The_post (); $ MySum + = get_post_meta ($ post-> ID, 'proyecto_votos', true); Endwhile; Wp_reset_postdata (); } // var_dump ($ arr_cat); ? & Gt;   

And it works fine but I can not show only with custom_sim values ​​for maximum 5 categories

Thanks a lot.

  $ args = array ('cat' => $ cat, 'post_type' = & gt; proyecto ',' meta_key '= & nbsp; for the top 5 posts  Gt; 'proyecto_votos',' orderby '=' meta_value_im ',' post_per_page '=> 5' // default by using the ASC command to top 5);   

post_on_page => -1 will show all the posts.



Comments