admin管理员组

文章数量:1130349

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()

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()

本文标签: navigationHow to add post page pagination to template part