categories - Only one post is showing on category page, why?

admin2025-06-06  1

My website categories are only showing one recent post, not all.

category.php code looks like this:

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

Please check and let me know.

My website categories are only showing one recent post, not all.

category.php code looks like this:

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

Please check and let me know.

Share Improve this question edited Nov 27, 2018 at 9:01 Krzysiek Dróżdż 25.6k9 gold badges53 silver badges74 bronze badges asked Nov 27, 2018 at 8:47 rudyardsrudyards 233 bronze badges 2
  • Please post your code here and not using some external sites... – Krzysiek Dróżdż Commented Nov 27, 2018 at 9:00
  • developer.wordpress/themes/basics/the-loop – Jacob Peattie Commented Nov 27, 2018 at 9:42
Add a comment  | 

1 Answer 1

Reset to default 0

It's pretty easy to see why your code shows only one post - there is no loop in your template file, so why should it show more posts than one?

To be honest... It looks more like single post template and not like category archive...

This should work a little bit better (or at least it should show more posts):

<?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(); ?>
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749149552a316787.html

最新回复(0)