<!--[archive/list]-->

<?php global $wp_query; 
$sql_query = $wp_query->request;
echo $sql_query; // Выведет SQL-запрос?>

<?php if( have_posts() ) : ?>

    <?php

        $counter = 0;

        while( have_posts() ) :

        $counter++;

    ?>

        <?php the_post(); ?>

        <?php get_template_part("template-parts/archive/list-item", "", ["counter" => $counter]); ?>

        <?php if ( wp_is_mobile() && $wp_query->current_post%3 ) : ?>

            <div class="newslist__item clearfix">

                <?php get_template_part("template-parts/ad/adfox/ad-inlist-2"); ?>

            </div>

        <?php endif; ?>

    <?php endwhile; ?>
<div class="pagination">
        <?php
        echo paginate_links(array(
            'base'         => str_replace(999999999, '%#%', esc_url(get_pagenum_link(999999999))),
            'format'       => '?paged=%#%',
            'current'      => max(1, get_query_var('paged')),
            'total'        => $wp_query->max_num_pages,
            'prev_text'    => '&laquo;',
            'next_text'    => '&raquo;',
            'type'         => 'plain',
            'add_args'     => false,
            'add_fragment' => '',
        ));
        ?>
    </div>

<?php else : ?>

    <?php get_template_part("template-parts/no-posts"); ?>

<?php endif; ?>

<!--[/archive/list]-->