让WordPress显示指定的header,footer或sidebar

| | Comments (1)



WordPress2.7里可以在主题中选择要显示的header、footer和sidebar文件。

以下代码将检测读者是否在"WordPress"分类里,如果是,将使用header-wordpress.php,否则使用默认header。

<?php if is_category('WordPress') {
get_header('wordpress');
} else {
get_header();
} ?>

同样,你可以用这个方法加载指定的footer和sidebar:

<?php get_footer('myfooter'); ?>
引入footer-myfooter.php文件

<?php get_sidebar('mysidebar'); ?>
引入sidebar-mysidebar.php文件

这里对应footer header 或sidebar的文件-后面的字符串.

1 Comments

看来确实对小农夫有难度。

Leave a comment

Archives

Ads by google

Pages

Powered by Movable Type 4.24-en

About this Entry

This page contains a single entry by 单点日志 published on December 3, 2009 11:20 PM.

天堂 地狱 was the previous entry in this blog.

全球IP地址将在明年(2010)耗尽,必须启用ipv6新的互联网协议 is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.