【发布时间】:2019-11-14 12:46:24
【问题描述】:
我设法让这段代码正常工作(它可以正确过滤帖子),但是它只显示了我正在测试的类别(“英格兰”)的 4 个可用帖子中的 2 个。
现场直播:https://medievalbritain.com/category/type/medieval-castles/
英格兰的类别页面,其中显示了我缺少的其他城堡:https://medievalbritain.com/category/locations/england/
我的if 有问题吗?一个页面中显示的帖子数量是否有限制?这可能是一个主题限制,有没有办法覆盖它?
这是我的代码:
<h3 class="archive-post-title">Castles from England</h3>
<!-- start content container for England -->
<div class="row">
<?php
// The Loop
if ( have_posts() ) : while ( have_posts() ) :
the_post();
if (in_category('England')):
?>
<div class="archive-post-box col-sm-2 col-md-3 col-lg-4">
<div>
<?php the_post_thumbnail(); ?>
</div>
<h2>
<a href="<?php the_permalink() ?>" rel="bookmark">
<?php the_title(); ?>
</a>
</h2>
<p class="archive-post-excerpt">
<?php the_excerpt(); ?>
</p>
</div>
<?php
endif;
endwhile;
endif;
?>
</div>
<!-- end content container for England-->
注意 I:我不是开发人员。
注意二:我在 Elementor 中使用 Futurio 主题。我创建的代码上面是这样的:
<?php get_header(); ?>
<?php futurio_generate_header( true, true, true, false, false ); ?>
<div class="container-fluid category-custom-header">
<header class="container text-left">
<h1>Medieval Castles</h1>
<?php
// Display optional category description
if ( category_description() ) : ?>
<div class="archive-meta"><?php echo category_description(); ?></div>
<?php endif; ?>
</header><!-- .archive-page-header -->
</div>
<?php futurio_breadcrumbs(); ?>
<?php futurio_content_layout(); ?>
【问题讨论】:
标签: php wordpress categories