0
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 no longer organizes by category, but rather, by the order of the key position , but shows all posts of all categories.
Thus, on the page of a category, it shows not only the posts of the category, but if I take the variables, as in the example below, it shows only the posts of the categories, but without the order by posicao
if (have_posts() ) :
while (have_posts() ) : the_post();