繁体   English   中英

并非所有帖子都在wordpress的“模板”页面上显示

[英]Not all posts are showing on Template page in wordpress

我制作了一个自定义模板,我想显示该模板中某些类别的所有帖子,但不包括某些帖子,我只收到10个帖子,但是我有100多个帖子,并且分页显示重复的帖子,我的意思是其他页面上的相同帖子,此代码中有任何错误

任何帮助将不胜感激

`

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

`

转到Wordpress管理员仪表板

在设置>阅读中

一个可用的“最多显示博客页面”选项(默认情况下为10)将其更改,您可以获取所有帖子

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM