plugins - Pagination shows Same posts

I made a custom template and I want to show all posts from certain category in this template excluding some ,I amgetti

I made a custom template and I want to show all posts from certain category in this template excluding some ,I am getting as per desired but pagination shows same posts whether I am on 1st page or second ,is there anything wrong with this template

any help would be highly appreciated

`

<?php /* Template Name: Blog Template */ ?>
<?php get_header(); ?>

<?php 
$homepageLayout = get_theme_mod('homepageLayout', 'no-sidebar');

?>

<div class="container pm-containerPadding-top-110 pm-containerPadding-bottom-90">
    <div class="row">

        <?php if($homepageLayout === 'no-sidebar') { ?>

            <div class="col-lg-12 col-md-12 col-sm-12">




                <?php
$query = new WP_Query('cat=106,93,138,136,86,23,103,83,84,92,78,137');


 if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post(); ?>

                    <?php get_template_part( 'content', 'post' ); ?>

                <?php }//end of posts ?>

                <?php } else { ?>
                     <p><?php _e('No posts were found.', 'medicallinktheme'); ?></p>
                <?php endif; ?> 

                <?php get_template_part( 'content', 'pagination' ); ?>

            </div>

        <?php } else if($homepageLayout === 'right-sidebar') {?>

            <!-- Retrive right sidebar post template -->
            <div class="col-lg-8 col-md-8 col-sm-12">

                <?php
$query = new WP_Query('cat=106,93,138,136,86,23,103,83,84,92,78,137');



 if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post(); ?>

                    <?php get_template_part( 'content', 'post' ); ?>

                <?php }//end of posts ?>

                <?php } else { ?>
                     <p><?php _e('No posts were found.', 'medicallinktheme'); ?></p>
                <?php endif; ?>  

                <?php get_template_part( 'content', 'pagination' ); ?>

            </div>

             <!-- Right Sidebar -->
             <?php get_sidebar('home'); ?>
             <!-- /Right Sidebar -->

        <?php } else if($homepageLayout === 'left-sidebar') { ?>

             <!-- Left Sidebar -->
             <?php get_sidebar('home'); ?>
             <!-- /Left Sidebar -->

            <!-- Retrive right sidebar post template -->
            <div class="col-lg-8 col-md-8 col-sm-12">

                <?php
$query = new WP_Query('cat=106,93,138,136,86,23,103,83,84,92,78,137');



 if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post(); ?>

                    <?php get_template_part( 'content', 'post' ); ?>

                <?php }//end of posts ?>

                <?php } else { ?>
                     <p><?php _e('No posts were found.', 'medicallinktheme'); ?></p>
                <?php endif; ?> 

                <?php get_template_part( 'content', 'pagination' ); ?>

            </div>

        <?php } else {//default full width layout ?>

            <div class="col-lg-12 col-md-12 col-sm-12">

<?php

$query = new WP_Query('cat=106,93,138,136,86,23,103,83,84,92,78,137');



 if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post(); ?>

                    <?php get_template_part( 'content', 'post' ); ?>

                <?php }//end of posts ?>

                <?php } else { ?>
                     <p><?php _e('No posts were found.', 'medicallinktheme'); ?></p>
                <?php } ?> 

                <?php get_template_part( 'content', 'pagination' ); ?>

            </div>

        <?php }  ?>

    </div> <!-- /row -->
</div> <!-- /container -->
<?php get_footer(); ?>

`

I made a custom template and I want to show all posts from certain category in this template excluding some ,I am getting as per desired but pagination shows same posts whether I am on 1st page or second ,is there anything wrong with this template

any help would be highly appreciated

`

<?php /* Template Name: Blog Template */ ?>
<?php get_header(); ?>

<?php 
$homepageLayout = get_theme_mod('homepageLayout', 'no-sidebar');

?>

<div class="container pm-containerPadding-top-110 pm-containerPadding-bottom-90">
    <div class="row">

        <?php if($homepageLayout === 'no-sidebar') { ?>

            <div class="col-lg-12 col-md-12 col-sm-12">




                <?php
$query = new WP_Query('cat=106,93,138,136,86,23,103,83,84,92,78,137');


 if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post(); ?>

                    <?php get_template_part( 'content', 'post' ); ?>

                <?php }//end of posts ?>

                <?php } else { ?>
                     <p><?php _e('No posts were found.', 'medicallinktheme'); ?></p>
                <?php endif; ?> 

                <?php get_template_part( 'content', 'pagination' ); ?>

            </div>

        <?php } else if($homepageLayout === 'right-sidebar') {?>

            <!-- Retrive right sidebar post template -->
            <div class="col-lg-8 col-md-8 col-sm-12">

                <?php
$query = new WP_Query('cat=106,93,138,136,86,23,103,83,84,92,78,137');



 if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post(); ?>

                    <?php get_template_part( 'content', 'post' ); ?>

                <?php }//end of posts ?>

                <?php } else { ?>
                     <p><?php _e('No posts were found.', 'medicallinktheme'); ?></p>
                <?php endif; ?>  

                <?php get_template_part( 'content', 'pagination' ); ?>

            </div>

             <!-- Right Sidebar -->
             <?php get_sidebar('home'); ?>
             <!-- /Right Sidebar -->

        <?php } else if($homepageLayout === 'left-sidebar') { ?>

             <!-- Left Sidebar -->
             <?php get_sidebar('home'); ?>
             <!-- /Left Sidebar -->

            <!-- Retrive right sidebar post template -->
            <div class="col-lg-8 col-md-8 col-sm-12">

                <?php
$query = new WP_Query('cat=106,93,138,136,86,23,103,83,84,92,78,137');



 if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post(); ?>

                    <?php get_template_part( 'content', 'post' ); ?>

                <?php }//end of posts ?>

                <?php } else { ?>
                     <p><?php _e('No posts were found.', 'medicallinktheme'); ?></p>
                <?php endif; ?> 

                <?php get_template_part( 'content', 'pagination' ); ?>

            </div>

        <?php } else {//default full width layout ?>

            <div class="col-lg-12 col-md-12 col-sm-12">

<?php

$query = new WP_Query('cat=106,93,138,136,86,23,103,83,84,92,78,137');



 if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post(); ?>

                    <?php get_template_part( 'content', 'post' ); ?>

                <?php }//end of posts ?>

                <?php } else { ?>
                     <p><?php _e('No posts were found.', 'medicallinktheme'); ?></p>
                <?php } ?> 

                <?php get_template_part( 'content', 'pagination' ); ?>

            </div>

        <?php }  ?>

    </div> <!-- /row -->
</div> <!-- /container -->
<?php get_footer(); ?>

`

Share Improve this question asked Sep 15, 2015 at 19:20 SteveSteve 112 bronze badges 1
  • 1 This will help. – Milo Commented Sep 15, 2015 at 19:39
Add a comment  | 

1 Answer 1

Reset to default 1

This made it work. Thanks Milo for link

<?php 

$args = array(
    'posts_per_page' => 12,
    'post_type'      => 'post',
    'paged'          => get_query_var( 'paged' ),
    'cat'            => '106,93,138,136,86,23,103,83,84,92,78,137' 
);

$query = new WP_Query($args);

?>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745060061a4608912.html

相关推荐

  • plugins - Pagination shows Same posts

    I made a custom template and I want to show all posts from certain category in this template excluding some ,I amgetti

    6小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信