<div id="content">
<div class="indexbg">
<!--完整的一个分类列表$display_categories = array(242,294,5,4,162,134,1,181); -->
<?php
$display_categories = array(5,4,134,1);
foreach ($display_categories as $category) { ?>
<div class="catlist">
<?php query_posts("showposts=4&cat=$category");
$wp_query->is_category = false; $wp_query->is_archive = false; $wp_query->is_home = true;
?>
<h3><a href="<?php echo get_category_link(1);?>"><?php single_cat_title(); ?></a></h3>
<ul>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
<?php else : ?><br /> 此分类暂无内容
<?php endif; ?></ul>
<h4><a href="<?php echo get_category_link($category);?>"><img src="<?php bloginfo('template_directory'); ?>/images/gdnr.png" /></a></h4>
</div><?php } ?>
<!--完整的一个分类列表-->
</div>
</div>我是想显示每个分类下面的文章主题 可是怎么也显示不出来 有人说是wordpress的版本问题 可是我用的是3.0.5的版本 而且我也把single_cat_title()函数更改过 也没有作用 求高手指教 我是刚接触PHP的 谢谢了
<div class="indexbg">
<!--完整的一个分类列表$display_categories = array(242,294,5,4,162,134,1,181); -->
<?php
$display_categories = array(5,4,134,1);
foreach ($display_categories as $category) { ?>
<div class="catlist">
<?php query_posts("showposts=4&cat=$category");
$wp_query->is_category = false; $wp_query->is_archive = false; $wp_query->is_home = true;
?>
<h3><a href="<?php echo get_category_link(1);?>"><?php single_cat_title(); ?></a></h3>
<ul>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
<?php else : ?><br /> 此分类暂无内容
<?php endif; ?></ul>
<h4><a href="<?php echo get_category_link($category);?>"><img src="<?php bloginfo('template_directory'); ?>/images/gdnr.png" /></a></h4>
</div><?php } ?>
<!--完整的一个分类列表-->
</div>
</div>我是想显示每个分类下面的文章主题 可是怎么也显示不出来 有人说是wordpress的版本问题 可是我用的是3.0.5的版本 而且我也把single_cat_title()函数更改过 也没有作用 求高手指教 我是刚接触PHP的 谢谢了
global $wp_query; if ( is_tag() )
return single_tag_title($prefix, $display); if ( !is_category() )
return; $cat = $wp_query->get_queried_object();
$my_cat_name = apply_filters(‘single_cat_title’, $cat->name);
if ( !empty($my_cat_name) ) {
if ( $display )
echo $prefix . $my_cat_name;
else
return $my_cat_name;
}
} //2.9 function single_cat_title($prefix = ”, $display = true ) {
$cat = intval( get_query_var(‘cat’) );
if ( !empty($cat) && !(strtoupper($cat) == ‘ALL’) ) {
$my_cat_name = apply_filters(‘single_cat_title’, get_the_category_by_ID($cat));
if ( !empty($my_cat_name) ) {
if ( $display )
echo $prefix.strip_tags($my_cat_name);
else
return strip_tags($my_cat_name);
}
} else if ( is_tag() ) {
return single_tag_title($prefix, $display);
}
} 把2.9的函数复制一个到/wp-includes/general-template.php,重命名single_cat_title2(),调用正常。