Log in

View Full Version : WordPress不同分类使用不同分类列表样式


topvip
2014-02-19, 12:07 PM
打开你wordpress模板所在目录,如是zeecompany, 进入wp-content/themes/zeecompany, 建立2个文件, 一个是product.php, 这个是给product分类用的; 另一个是news.php,这个是给news分类用的. 复制archive.php内的所有内容到这2个文件中.

打开archive.php, 删除里面的所有内容, 加入<?php
if ( is_category(1) ) {
include(TEMPLATEPATH . '/product.php');
} else {
include(TEMPLATEPATH . '/news.php');
}
?>

修改product.php, news.php以适合相应分类的内容列表的显示方式.如news.php可修改成如下:
<?php get_header(); ?>

<div id="wrap">

<div id="content">

<?php if (is_category()) { ?><h2 class="arh"><?php _e('Archive for', 'themezee_lang'); ?> <?php echo single_cat_title(); ?></h2>
<?php } elseif (is_date()) { ?><h2 class="arh"><?php _e('Archive for', 'themezee_lang'); ?> <?php the_time(get_option('date_format')); ?></h2>
<?php } elseif (is_author()) { ?><h2 class="arh"><?php _e('Author Archive', 'themezee_lang'); ?></h2>
<?php } elseif (is_tag()) { ?><h2 class="arh"><?php _e('Tag Archive for', 'themezee_lang'); ?> <?php echo single_tag_title('', true); ?></h2>
<?php } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?><h2 class="arh"><?php _e('Archives', 'themezee_lang'); ?></h2><?php } ?>


<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

<p><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></p>

</div>

</div>

<?php get_sidebar(); ?>
</div>

<?php get_footer(); ?>