【发布时间】:2021-03-03 01:05:56
【问题描述】:
我想在archive.php 页面上显示所有类别的帖子。我制作它的方式只适用于类别页面。例如,如果我访问“myurl/category/test-category/”,该页面可以正常工作,但它只显示来自“测试类别”的帖子。如果我访问“myurl/category/”,它只会返回一个空白页。
我的存档.php:
<?php get_header(); ?>
<div class="custom-container archive-wrapper">
<?php if(have_posts() ): while (have_posts() ): the_post(); ?>
<div class="blog-post-archive">
<div class="img-archive-wrapper d-xl-flex">
<img src="<?php echo wp_get_attachment_url(get_post_thumbnail_id( $post->ID ), 'medium' ); ?>" alt="Blog image" class="blog-image-archive">
<div class="blog-post-archive-infos">
<h2 class="archive-title"><?php the_title(); ?></h2>
<span class="post-date-archive"><?php echo get_the_date(); ?></span>
<p><?php the_excerpt( ) ?></p>
<a href="<?php the_permalink();?>" class="see-more-posts"> Ver mais</a>
</div>
</div>
</div>
<?php endwhile; else: endif; ?>
<div class="pagination__links">
<?php the_posts_pagination( ); ?>
</div>
</div>
<?php get_footer(); ?>
【问题讨论】:
-
您想显示“myurl/category/”上的所有帖子,其中“category”是准确的词,而不是特定的类别,对吧?
-
是的!我想在页面上显示所有类别,例如“category-1”、“category-2”等
-
等等,所有类别还是网站所有类别的所有帖子?
-
糟糕,抱歉。所有类别的所有帖子。
-
在下面查看我的答案