$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>navigation - How to add post page pagination to template part?|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

navigation - How to add post page pagination to template part?

matteradmin6PV0评论

How can I get this page to display the post page pagination? I'm using a custom blog template with a get_template_part.

/

<?php
/**
 * Template part for displaying blog content in page_blog.php
 *
 * @link 
 *
 * @package nowitconnects
 */
?>
<!-- blogs ================================================== -->
<section class="">
    <div class="">
        <div class="row">
            <!-- START BLOG LOOP -->
            <?php $the_query = new WP_Query( array( 'post_type' => 'post' ) ); 
            while( $the_query->have_posts() ) : $the_query->the_post(); ?>
                <div class="col-lg-8 col-md-8">
                    <div class="aside-feature">
                        <div class="col-md-4">
                            <div class="">
                                <?php // check if the post has a Post Thumbnail assigned to it.
                                if ( has_post_thumbnail() ) {
                                    the_post_thumbnail('full', array('class' => 'img-responsive'));
                                } ?><br/>
                            </div>
                        </div>
                        <div class="col-md-7">
                            <?php the_title( '<h3><a href="'.get_permalink( $id ).'">', '</a></h3>' ); ?>
                            <?php the_excerpt(); ?><br/><hr/><br/>
                        </div>
                    </div>
                </div>
            <?php endwhile; ?> <!-- END BLOG LOOP -->
            <aside id="secondary" class="widget-area" role="complementary">
                <?php dynamic_sidebar( 'sidebar-1' ); ?>
            </aside><!-- #secondary -->
        </div>
    </div>
</section>

How can I get this page to display the post page pagination? I'm using a custom blog template with a get_template_part.

https://www.nowitconnects/blog/

<?php
/**
 * Template part for displaying blog content in page_blog.php
 *
 * @link https://codex.wordpress/Template_Hierarchy
 *
 * @package nowitconnects
 */
?>
<!-- blogs ================================================== -->
<section class="">
    <div class="">
        <div class="row">
            <!-- START BLOG LOOP -->
            <?php $the_query = new WP_Query( array( 'post_type' => 'post' ) ); 
            while( $the_query->have_posts() ) : $the_query->the_post(); ?>
                <div class="col-lg-8 col-md-8">
                    <div class="aside-feature">
                        <div class="col-md-4">
                            <div class="">
                                <?php // check if the post has a Post Thumbnail assigned to it.
                                if ( has_post_thumbnail() ) {
                                    the_post_thumbnail('full', array('class' => 'img-responsive'));
                                } ?><br/>
                            </div>
                        </div>
                        <div class="col-md-7">
                            <?php the_title( '<h3><a href="'.get_permalink( $id ).'">', '</a></h3>' ); ?>
                            <?php the_excerpt(); ?><br/><hr/><br/>
                        </div>
                    </div>
                </div>
            <?php endwhile; ?> <!-- END BLOG LOOP -->
            <aside id="secondary" class="widget-area" role="complementary">
                <?php dynamic_sidebar( 'sidebar-1' ); ?>
            </aside><!-- #secondary -->
        </div>
    </div>
</section>
Share Improve this question edited Nov 21, 2018 at 23:10 Akshat 1,19711 silver badges22 bronze badges asked Nov 21, 2018 at 21:04 angeladesignangeladesign 11 bronze badge 1
  • 1 The blog shouldn't be a page template. You should set a page for posts in Settings > Reading and then make sure an appropriate template from the template hierarchy exists. That template should use the main loop. Then pagination will work properly. – Jacob Peattie Commented Nov 22, 2018 at 0:07
Add a comment  | 

1 Answer 1

Reset to default 0

Right after the endwhile line, try adding...

<?php the_posts_pagination(); ?>

more info on the_posts_pagination()

Post a comment

comment list (0)

  1. No comments so far