我的工作离TwentyTwelve主题,我已经通过了环无法获得类别显示
get_header(); ?>
<div id="primary" class="site-content">
<div id="content" role="main" class="clearfix">
<?php
$terms = get_the_category();
$count = count($terms);
echo '<ul id="post-filter">';
echo '<li><a href="#all" title="">All</a></li>';
if ($count > 0){
foreach ($terms as $term) {
$termname = strtolower($term->name);
$termname = str_replace(' ', '-', $termname);
echo '<li><a href="#'.$termname.'" title="" rel="'.$termname.'">'.$term->name.'</a></li>';
}
}
echo "</ul>";
?>
<div id="mwrapper">
<?php query_posts('cat=-6,-7'); ?>
<?php if (have_posts()) : ?>
<?php /* Start the Loop */ ?>
<?php while (have_posts()) : the_post(); ?>
<div class="box">....
我试图创建一个过滤器将过滤前加入这个片段修改索引文件通过博客文章。像演示here一样。目前我有五个类别:机构注释,设计笔记,精选,幽默,未分类。每个类别至少有一篇文章,但它似乎只是在设计笔记中。
我也试图改变get_the_category();
到wp_list_categories();
但最终显示的所有类别。
Source我碰到的片段。
首先,它是更好地使用'$条款而─> slug',而不是'用strtolower()'和'str_replace()函数'。 – doublesharp 2013-04-30 16:22:08