admin管理员组文章数量:1130349
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
1 Answer
Reset to default 0It'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(); ?>
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
1 Answer
Reset to default 0It'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(); ?>
本文标签: categoriesOnly one post is showing on category pagewhy
版权声明:本文标题:categories - Only one post is showing on category page, why? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749149528a2323576.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论