簡體   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