I can't get pagination to work with this custom post type category archive. The custom post type is called 'blog'.
<h2 class="category-h2">Blogs Category: <?php single_cat_title(); ?></h2>
<pre>
</pre>
<div class="row">
<?php
$my_cat_value = get_query_var('cat_value');
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$args = array(
'post_type' => 'blog',
'category_name' => $my_cat_value,
'paged' => $paged,
'posts_per_page' => 10
);
$query = new WP_Query( $args );
$posts = $query->posts;
foreach ( $posts as $post ) {
echo '<div class="col-6">';
$title = get_the_title();
$url = get_permalink();
$authID = $post->post_author;
$author = get_user_by( 'ID', $authID );
$author_display_name = $author->display_name;
//* Large image
$image = get_field( 'acf_cb_header_image' );
$size_m = 'cs_cb_medium';
$url_m = $image[ 'sizes' ][ $size_m ];
?>
<a href="<?php the_permalink(); ?>">
<?php
if ( empty( $url_m ) ) {
echo '…';
}
else {
echo '<img src="' . $url_m .'" class="responsive-image" width="340" height="190"></a>';
}
?>
<a href="<?php the_permalink(); ?>">
<?php
echo '<h2 class="cb-archive-h2">' . $title . '</h2></a>';
//* The Excerpt
echo '<div class="custom-blog-content">';
echo the_excerpt();
echo '</div>';
//* The Date
echo '<span class="cb-meta-date">';
echo get_the_date('M j, Y');
echo '</span>';
//* The Author
echo '<span class="cb-meta-cat cb-meta-author">';
// echo $author_display_name;
echo '<a href="' . get_author_posts_url($post->post_author) . '">' . $author_display_name . '</a>';
echo '</span>';
echo '</div><!-- /col-6 -->';
}
?>
</div> <!-- /row -->
<div class="row">
<div class="col-12">
<?php the_posts_pagination( array( 'mid_size' => 2 ) ); ?>
</div>
</div>
<?php wp_reset_postdata(); ?>
<aside id="sidebar" class="sidebar">
<?php
//* Custom Blog Sidebar
dynamic_sidebar( 'blogs-sidebar' );
?>
</aside>
<?php get_footer(); ?>