wordpress函数参考/get header
-描述:
当前主题目录中header.php被引入,如果一个名字被指定,则指定的头文件header-special.php就被引入。如果主题不包含header.php文件,则默认主题中的header.php就会被引入。
-使用:
-参数:
$name
(字符串)(可选)调用header-name.php,默认:空
-例子:
404页
如下代码是一个简单的用于“HTTP 404:Not Found”的模板(在主题中应引入名为404.php)
Error 404 – Not Found
<?php get_sidebar(); ?>
<?php get_footer(); ?>
多头文件
不同的页面不同的头文件
get_header(‘home’);
elseif ( is_404() ) :
get_header(‘404′);
else :
get_header();
endif;
?>
函数参考/get sidebar
-描述:
当前主题目录的sidebar.php被引入,如果一个名字被指定则专用侧边栏文件sidebar-special.php被引入。如果当前主题没有sidebar.php,那么默认主题中的sidebar.php被引入。
-使用:
-参数:
$name
(字符串)(可选)调用sidebar-name.php,默认:空
-例子:
404页
同header.php
左侧边栏和右侧边栏
主题中有两个侧边栏
<?php get_sidebar(‘left’); ?>
<?php get_sidebar(‘right’); ?>
<?php get_footer(); ?>
多侧边栏
不同页面不同侧边栏
if ( is_home() ) :
get_sidebar(‘home’);
elseif ( is_404() ) :
get_sidebar(‘404′);
else :
get_sidebar();
endif;?>
函数参考/get search form
-描述:
用searchform.php显示搜索表
-使用:
-参数:
没有参数
-例子:
无
函数参考/comments template
-描述:
加载评论模板,在单页文章或页面中显示
-使用:
-参数:
$file
(字符串)(可选)被加载的文件,默认:/comments.php
$separate_comments
(布尔)(可选)是否按评论类型分离评论,默认:否
-例子:
无
-注:
* Uses global: (array) $comment List of comment objects for the current post
* Uses: $wpdb
* Uses: $id
* Uses: $post
* Uses: $withcomments Will not try to get the comments if the post has none.
函数参考/get footer
-描述:
当前主题目录中的footer.php被引入,如果一个名字被指定则被指定名字的footer文件footer-special.php被引入。如果当前主题没有footer.php则默认主题中的footer.php被引入。
-使用:
-参数:
$name
(字符串)(可选)调用footer-name.php,默认:空
-例子:
404页,同get header和ger sidebar
多footer
不同页面对应不同footer
if ( is_home() ) :
get_footer(‘home’);
elseif ( is_404() ) :
get_footer(‘404′);
else :
get_footer();
endif;?>
调用任意模板文件
比如一个名为header2的模板,想要在模板内调用它的话,可以用下面的语句,TEMPLATEPATH是文件路径,不用动它,只要改后面的文件目录:
这里有英文原版文档
右上方更多相关内容/站内搜索-关键词请用空格隔开
发表留言