<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 />&nbsp;&nbsp;&nbsp;此分类暂无内容
            <?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的 谢谢了

解决方案 »

  1.   

    wordpress升级到3.0后,发现首页调用single_cat_title()分类名不显示,对比2.9版本和3.0版本的single_cat_title()函数,发现原来新版本函数内容有更新造成,两个函数对比 //3.0 function single_cat_title($prefix = ”, $display = true ) { 
    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(),调用正常。