0
类
我有一个category.php与脚本里面:显示所有的文章
<?php $categories = get_the_category(); ?>
<?php $category_id = $categories[0]->cat_ID; ?>
<?php query_posts('cat='.$category_id); ?>
<?php while (have_posts()) : ;?>
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
<?php if (has_post_thumbnail($post->ID)): ?>
<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'single-post-thumbnail'); ?>
<div class="article">
<div class="article_image" style="background-image: url('<?php echo $image[0]; ?>')">
<i class="fa article_favourite"><?php wpfp_link() ?></i>
</div>
<a href="<?php echo get_permalink(); ?>" id="half_height_link"></a>
<h3><a href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a></h3>
<div class="article_subheading_wrapper">
<p>
<!--Cut the long text -->
<?php
$string = substr(get_field("subheading"), 0, 100);
echo $string."… ";
?>
</p>
</div>
<div class="bottom">
<ul>
<li><p id="views"><img id="eye" src="<?php bloginfo('template_directory'); ?>/icons/watched_icon.svg"> <span><?php if(function_exists('the_views')) { the_views(); } ?></span></p></li>
<li><p id="likes"><i class="fa"></i><?php if(function_exists('like_counter_p')) { like_counter_p(''); }
?></p></li>
<li><p id="comments"><i class="fa fa-comment"></i> <?php comments_number('0', '1', '%'); ?></p></li>
</ul>
</div>
</div>
<?php endif; ?>
<?php endwhile; ?>
它应该是显示属于该类别的所有信息。我这样做,但它只显示最近的一次并且无限次数。 我做错了什么?
什么是'have_posts()'方法?它返回什么? – iamsleepy
更容易找到这里的解决方案[WordPress的类别,得到它的所有帖子] [1] [1]:https://stackoverflow.com/questions/6912572/wordpress-category-get-all-its-posts ?RQ = 1 –