Skip to content

Instantly share code, notes, and snippets.

@wpflames
Created March 16, 2022 12:05
Show Gist options
  • Select an option

  • Save wpflames/35ebff0ef88e77c82463f5ae88e77d4d to your computer and use it in GitHub Desktop.

Select an option

Save wpflames/35ebff0ef88e77c82463f5ae88e77d4d to your computer and use it in GitHub Desktop.
Archive with numbered pagination
<?php
// Archive
/************************************/
defined( 'ABSPATH' ) || exit;
get_header();
?>
<main id="primary" class="site-main">
<div class="wrap">
<?php
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$args = array(
'posts_per_page' => 10,
'paged' => $paged
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) : ?>
<header class="page-header">
<h1 class="page-title">News</h1>
<?php
the_archive_description( '<div class="archive-description">', '</div>' );
?>
</header><!-- .page-header -->
<?php
/* Start the Loop */
while ( $the_query->have_posts() ) :
$the_query->the_post();
/*
* Include the Post-Type-specific template for the content.
* If you want to override this in a child theme, then include a file
* called content-___.php (where ___ is the Post Type name) and that will be used instead.
*/
get_template_part( 'template-parts/content', 'archive' );
endwhile;
the_posts_pagination( array(
'mid_size' => 2,
) );
else :
get_template_part( 'template-parts/content', 'none' );
endif;
?>
</div>
</main><!-- #main -->
<?php
get_sidebar();
get_footer();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment