我正在尝试创建一个列出每个类别内容的页面。我设法创建了列表。我现在需要获取类别的名称。我有以下代码:
<ul>
<li> CATEGORY NAME HERE </li>
<?php query_posts('cat=0'); ?>
<?php while ( have_posts() ) : the_post(); ?>
<li>
<a href="<?php echo get_permalink(); ?>">
<?php the_title(); ?></a>
</li>
<?php endwhile; ?>
</ul>
如何调用第一类(0)的名称?
当前编辑:为什么不会有多个作品?
<div class="first-col">
<ul>
<?php query_posts('cat=0'); ?>
<?php while ( have_posts() ) : the_post(); ?>
<li> <?php $category = get_the_category();
echo $category[0]->cat_name;
?> </li>
<li>
<a href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a>
</li>
<?php endwhile; ?>
</ul>
</div>
<div class="first-col">
<ul>
<li> <?php $category = get_the_category();
echo $category[0]->cat_name;?> </li>
<?php query_posts('cat=3'); ?>
<?php while ( have_posts() ) : the_post(); ?>
<li>
<a href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a>
</li>
<?php endwhile; ?>
</ul>
</div>