Post pagination shows 20 most recent posts
-
I have a theme that uses a Custom Post type to display blogs as shown here. A list of clickable images that represent my blog posts.
There are as I write this 70 such blogs on the database.
“blog pages show at most” 1 posts. – This is the only setting that seems to make pagination links show up at all.
In code, the “posts_per_page” property is set to 10.
The pagination I need seems to be working but only for the first 2 pages of posts to the most recent 20 posts (10 per page).
I’m at a loss. How do I get the rest of the posts to show up? Is it possible for a custom post type?
index.php
<?php /* Template Name: index.php - blog_posts CPT */ ?> <?php $page_title = "Home"; ?> <?php require("template-parts/header.php"); ?> <section class="article_block_primary"> <?php get_template_part("primary","content"); ?> <?php require("template-parts/content-blocks/primary.php"); ?> </section> <section class="article_block_secondary"> <?php get_template_part("content", "secondary-content"); ?> <?php require("template-parts/content-blocks/secondary.php"); ?> </section> <?php require("template-parts/footer.php"); ?>
primary.php
<?php //echo "primary.php"; ?> <!-- Blog Posts Custom Post Type Loop --> <?php $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : get_query_var( 'paged' ); $args = array('paged' => $paged); $query = new WP_Query( $args ); $blog_posts = new WP_Query( array( 'post_type' => 'blog_posts', // 'posts_per_page' => 10, // posts per page - CPT 'paged' => $paged ) ); $latest_post = new WP_Query( array( 'post_type' => 'blog_posts', // 'posts_per_page' => 1, // This is the amount of posts per page you want to show ) ); ?> <?php if( $blog_posts->have_posts() ) { ?> <!-- pagination --> <div class="next"> <?php next_posts_link( 'Older Posts' ); ?> </div> <div class="previous"> <?php previous_posts_link( 'Newer Posts' ); ?> </div> <?php echo paginate_links( array( 'base' => str_replace( 999999999, '%#%', esc_url( get_pagenum_link( 999999999 ) ) ), 'total' => $query->max_num_pages, 'current' => max( 1, get_query_var( 'paged' ) ), 'format' => '?paged=%#%', 'show_all' => false, 'type' => 'plain', 'end_size' => 2, 'mid_size' => 1, 'prev_next' => true, 'prev_text' => sprintf( '<i></i> %1$s', __( 'Newer Posts', 'jgdm_blog' ) ), 'next_text' => sprintf( '%1$s <i></i>', __( 'Older Posts', 'jgdm_blog' ) ), 'add_args' => false, 'add_fragment' => '', ) ); ?> <?php the_posts_pagination( array('mid_size' => 3) ); ?> <!-- // The content you want to loop --> <?php while ( $blog_posts->have_posts() ) { $blog_posts->the_post(); ?> <article> <article class="article_title"> <?php if( get_field('article_featured_image') ): ?> <img />" /> <?php endif; ?> <a>"> <div class="article_blurb"> <?php if( get_field('article_title') ): ?> <h2> <?php the_field('article_title'); ?> </h2> <?php endif; ?><!-- 70 chars --> <?php if( get_field('article_blurb') ): ?> <?php the_field('article_blurb'); ?> <?php endif; ?><!-- 250 chars --> </div> </a> </article> <article class="author_block"> <div class="author_information"> Author: <a>/jgdm_blog/author-page/" class="author_links" alt="Author information" title="Author information"><?php echo get_the_author_meta( 'nicename', $author_id ); ?> </a> Posted: <a>/jgdm_blog/site-archive/" class="author_links" alt="Author information" title="Author information"><?php echo get_the_date("F j, Y g:i a"); ?> </a> </div> </article> </article> <?php } //end while ?> <?php } else { //end loop content ?> <article> <!-- If No content found--> <h3 class="article_title">No Content</h3> <p class="article_content">No Posts Available <?php esc_html_e( 'Sorry, no posts matched your criteria.' ); ?> </article> <?php } ?> <!-- the wordpress loop end --> <!-- Reset post data --> <?php wp_reset_postdata(); ?> <!-- pagination --> <div class="next"> <?php next_posts_link( 'Older Posts' ); ?> </div> <div class="previous"> <?php previous_posts_link( 'Newer Posts' ); ?> </div>
- This topic was modified 3 years, 10 months ago by .
- This topic was modified 3 years, 10 months ago by .
- This topic was modified 3 years, 10 months ago by . Reason: redundant link removed
The page I need help with: [log in to see the link]
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Post pagination shows 20 most recent posts’ is closed to new replies.