web-dev-qa-db-ja.com

カテゴリページには1つの投稿しか表示されていません。なぜですか?

私のウェブサイトのカテゴリでは、最近の投稿が1つしか表示されていません。

category.phpコードは次のようになります。

<?php
get_header(); 
/**
 * The template for displaying Category pages
 */
quality_breadcrumbs();
?>

<section id="section-block" class="site-content">
    <div class="container">
        <div class="row">
        <!--Blog Posts-->
        <?php echo '<div class="col-md-'.( !is_active_sidebar( "sidebar-primary" ) ?"12" :"8" ).' col-xs-12">'; ?>
            <article class="cat-post">  
            <figure class="cat-figure">
        <?php $defalt_arg =array('class' => "img-responsive"); ?>
            <?php if(has_post_thumbnail()): ?>
            <a  href="<?php the_permalink(); ?>">
                <?php the_post_thumbnail($defalt_arg); ?>
            </a>
            <?php endif; ?> 

        </figure>
        <div>

            <?php if($current_options['home_meta_section_settings'] == '' ) {?>

<?php } ?>

            <header class="entry-header">
                <h2 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
            </header>   
            <div class="entry-content">
                <?php the_excerpt(__('Read More','quality')); ?>

            <?php if($current_options['home_meta_section_settings'] == '' ) {?>     

            <span class="entry-meta">
                <?php $cat_list = get_the_category_list();
                if(!empty($cat_list)) { ?>

            <span class="author-image"> <?php echo ' ';?><a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) );?>"><?php echo get_the_author();?></a> |</span><span class="cat-links"><?php _e('','quality');?><a href="<?php the_permalink(); ?>"><?php the_category(' '); ?></a></span> |  <a class="entry-date" href="<?php echo get_month_link(get_post_time('Y'),get_post_time('m')); ?>"> <?php echo get_the_date('M j, Y'); ?></a>
                <?php } ?>
                </span>
            </div>
            <?php } ?>
        </div>
</article>              
        <?php wp_link_pages();?>    
        <!--/Blog Content-->
        <?php comments_template('',true); ?>
        </div>
        <?php get_sidebar(); ?>
    </div>
</section>
<?php get_footer(); ?>

確認して教えてください。

1
rudyards

コードに1つの投稿しか表示されない理由は非常に簡単です。テンプレートファイルにループがないため、なぜ複数の投稿が表示されるのでしょうか。

正直に言うと...これは単一の投稿テンプレートのように見え、カテゴリアーカイブのようには見えません...

これはもう少しうまくいくはずです(あるいは少なくとももっと多くの投稿を表示するべきです):

<?php
get_header(); 
/**
 * The template for displaying Category pages
 */
quality_breadcrumbs();
?>

<section id="section-block" class="site-content">
    <div class="container">
        <div class="row">
        <!--Blog Posts-->
        <?php echo '<div class="col-md-'.( !is_active_sidebar( "sidebar-primary" ) ?"12" :"8" ).' col-xs-12">'; ?>
            <?php while ( have_posts() ) : the_post(); ?>
            <article class="cat-post">  
                <figure class="cat-figure">
                    <?php $defalt_arg =array('class' => "img-responsive"); ?>
                    <?php if(has_post_thumbnail()): ?>
                    <a  href="<?php the_permalink(); ?>">
                        <?php the_post_thumbnail($defalt_arg); ?>
                    </a>
                    <?php endif; ?> 
                </figure>

                <div>    
                    <?php if($current_options['home_meta_section_settings'] == '' ) {?>

                    <?php } ?>

                    <header class="entry-header">
                        <h2 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                    </header>   

                    <div class="entry-content">
                        <?php the_excerpt(__('Read More','quality')); ?>

                        <?php if($current_options['home_meta_section_settings'] == '' ) { ?>     

                        <span class="entry-meta">
                            <?php $cat_list = get_the_category_list();
                                if(!empty($cat_list)) {
                            ?>

                            <span class="author-image"> <?php echo ' ';?><a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) );?>"><?php echo get_the_author();?></a> |</span><span class="cat-links"><?php _e('','quality');?><a href="<?php the_permalink(); ?>"><?php the_category(' '); ?></a></span> |  <a class="entry-date" href="<?php echo get_month_link(get_post_time('Y'),get_post_time('m')); ?>"> <?php echo get_the_date('M j, Y'); ?></a>
                            <?php } ?>
                        </span>
                    <?php } ?>
                </div>
            </article>    
            <?php endwhile; ?>          

            <?php wp_link_pages();?>    
            <!--/Blog Content-->
            <?php comments_template('',true); ?>
        </div>
        <?php get_sidebar(); ?>
    </div>
</section>
<?php get_footer(); ?>
0