网络营销电子商务研究中心

网络营销电子商务研究中心 (https://www.0058.net/index.php)
-   WordPress (https://www.0058.net/forumdisplay.php?f=68)
-   -   WordPress不同分类使用不同分类列表样式 (https://www.0058.net/showthread.php?t=4631)

topvip 2014-02-19 12:07 PM

WordPress不同分类使用不同分类列表样式
 
打开你wordpress模板所在目录,如是zeecompany, 进入wp-content/themes/zeecompany, 建立2个文件, 一个是product.php, 这个是给product分类用的; 另一个是news.php,这个是给news分类用的. 复制archive.php内的所有内容到这2个文件中.

打开archive.php, 删除里面的所有内容, 加入
Code:

<?php
if ( is_category(1) ) {
    include(TEMPLATEPATH . '/product.php');
} else {
    include(TEMPLATEPATH . '/news.php');
}
?>

修改product.php, news.php以适合相应分类的内容列表的显示方式.如news.php可修改成如下:
Code:

<?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(); ?>



All times are GMT +8. The time now is 06:28 PM.

Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.