In my blog, I have different categories, and in each post I created a custom field with the key posicao
with numeric values. This is the code I have
$query = new WP_Query(array(
'meta_key' => 'posicao',
'orderby' => 'meta_value_num',
'order' => 'ASC'
));
if ( $query->have_posts() ) :
while ( $query->have_posts() ) : $query->the_post();
the_content();>
endwhile;
wp_reset_postdata();
else: echo "Não existem artigos";
endif;
However, on the category page, it does not organize more by category, but rather by the order of the 'keyposition', but it shows all posts of all categories.
So, in the page of a categories, not only shows the posts of the category, but if you shoot the variables, as in the example below, it only shows the posts of the categories, but without the order by posicao
if (have_posts() ) :
while (have_posts() ) : the_post();