我正在为bludit开发一个中等主题的版本。
默认情况下,主题在主页上显示页面第一部分中所有文章的列表。我想显示一个特定类别的文章列表。
我试图添加一个与正确类别匹配的if
条件,但我可能是错的。
这是我尝试过的:
<?php if ($WHERE_AM_I == 'home'): ?>
<!-- Begin Featured
================================================== -->
<section class="featured-posts">
<div class="section-title">
<h2><span>La structure</span></h2>
</div>
<div class="card-columns listfeaturedtag">
<?php if ($category->key() == 'structure'): ?>
<?php
// Get the first and second page from the content
$featured = array_slice($content, 0, 2);
$content = array_slice($content, 2); ?>
<?php endif; ?>
<?php
foreach ($featured as $page):
?>
<!-- begin post -->
<!-- Here goes the code for each post -->
<!-- end post -->
<?php endforeach; ?>
</div>
</section>
<!-- End Featured
================================================== -->
<?php endif; ?>
我希望它显示名为structure
的类别中的文章,但我的页面上没有任何内容。
以下是一些关于 bludit 中类别的片段。
好的,我找到了如何做我想做的事:
<?php
$categoryKey = 'structure';
$category = getCategory($categoryKey);
$featured = array_slice($category->pages(), 0, 3);
$content = array_slice($content, 1); ?>
<?php
foreach ($featured as $pageKey):
?>
<?php $page = new Page($pageKey); ?>