【发布时间】:2017-01-16 16:26:36
【问题描述】:
我发现我的网站 (www.inunfuturoaprile.it) 使用了一个不包含 category.php 模板的最小 Wordpress 主题。我自己创建了模板:目标是让页面显示属于特定类别的帖子列表。不幸的是,由于我对 php 的了解很少,代码似乎无法正常工作:每个类别我只看到一个帖子(例如https://www.inunfuturoaprile.it/politica/)。
category.php 文件代码如下:
<?php
/**
* Template di Categoria
*/
get_header(); ?>
<div id="content">
<?php
// Check if there are any posts to display
if ( have_posts() ) : ?>
<?php
// Since this template will only be used for Design category
// we can add category title and description manually.
// or even add images or change the layout
?>
<h1><strong><?php single_cat_title(); ?></strong>: Elenco Articoli</h1>
<div class="entry">
<?php
// The Loop
while ( have_posts() ) : the_post(); ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a> // <small><?php the_time('j F Y') ?></small>
<?php endwhile; // End Loop
else: ?>
<h2 class="center">Not Found</h2>
<p class="center">Sorry, but you are looking for something that isn't here.</p>
<?php endif; ?>
</div>
</div>
<?php get_footer(); ?>
有人可以帮助我吗?谢谢你:)
【问题讨论】: