If your theme is creating a new query for the main page loop it is doing something very wrong. To get a category archive, all you should need is a template named according to one of these patterns, depending on your need:
category-{slug}.php
– If the category’s slug isnews
, WordPress will look forcategory-news.php
.category-{id}.php
– If the category’s ID is6
, WordPress will look forcategory-6.php
.category.php
With a Loop in it that looks like this:
if( have_posts() ) {
echo '<div class="list-posts">';
while( have_posts() ) {
$posts->the_post();
get_template_part( 'content', get_post_format() );
}
echo '</div>';
wp_reset_postdata();
} else {
echo '<div class="alert alert-error">'.esc_html__('Sorry. There are no posts to display', 'gon').'</div>';
}
Plus, of course, whatever code your theme needs surrounding that. I can’t really guess what that code looks like.