<section>
<div class="cards">
<?php
global $wp_query;
$wp_query = new WP_Query( array(
'numberposts' => -1,
'category_name' => get_post_meta($post->ID, 'category_name_child', true),
'post_type' => 'post',
'posts_per_page' => '3',
));
if ( $wp_query->have_posts() ) :
while ( $wp_query->have_posts() ) :
$wp_query->the_post();
<figure class="card__post">
<?php the_post_thumbnail('adv_thumbnail'); ?>
<figcaption class="">
<h2 class=""><?php the_title(); ?></h2>
<a href="<?php the_permalink() ?>"
target="_blank"
rel="noopener noreferrer">
<?php echo get_post_meta($post->ID, 'btn_card_value', true); ?> »
</a>
</figcaption>
</figure>
<?php endwhile; ?>
</div>
<div style="margin: 10px auto;">
<?php
$args = array(
'show_all' => false, // показаны все страницы участвующие в пагинации
'end_size' => 1, // количество страниц на концах
'mid_size' => 1, // количество страниц вокруг текущей
'prev_next' => true, // выводить ли боковые ссылки "предыдущая/следующая страница".
'prev_text' => __('« Previous'),
'next_text' => __('Next »'),
'add_args' => false, // Массив аргументов (переменных запроса), которые нужно добавить к ссылкам.
'add_fragment' => '', // Текст который добавиться ко всем ссылкам.
'screen_reader_text' => __( 'Posts navigation' ),
'class' => 'pagination', // CSS класс, добавлено в 5.5.0.
);
the_posts_pagination( $args ); ?>
</div>
<?php else: ?>
Записей нет.
<?php endif; ?>
<?php wp_reset_query(); ?>
</section>