wordpress模板常用函数集锦
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'><strong>基本模板文件</strong></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
style.css : CSS(样式表)文件<br>
index.php : 主页模板<br>
archive.php : Archive/Category模板<br>
404.php : Not Found 错误页模板<br>
comments.php : 留言/回复模板<br>
footer.php : Footer模板<br>
header.php : Header模板<br>
sidebar.php : 侧栏模板<br>
page.php : 内容页(Page)模板<br>
single.php : 内容页(Post)模板<br>
searchform.php : 搜索表单模板<br>
search.php : 搜索结果模板</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
<strong>基本条件判断Tag</strong></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
is_home() : 是否为主页<br>
is_single() : 是否为内容页<br>
(Post) is_page() : 是否为内容页<br>
(Page) is_category() : 是否为Category/Archive页<br>
is_tag() : 是否为Tag存档页<br>
is_date() : 是否为指定日期存档页<br>
is_year() : 是否为指定年份存档页<br>
is_month() : 是否为指定月份存档页<br>
is_day() : 是否为指定日存档页<br>
is_time() : 是否为指定时间存档页<br>
is_archive() : 是否为存档页<br>
is_search() : 是否为搜索结果页<br>
is_404() : 是否为 “HTTP 404: Not Found” 错误页<br>
is_paged() : 主页/Category/Archive页是否以多页显示</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
<strong>Header部分PHP函数</strong></p>
<p sizcache="13" sizset="55" style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
<!–p bloginfo(’name’);–>: 博客名称(Title)<br>
<!–p bloginfo(’stylesheet_url’);–>: CSS文件路径<br>
<!–p bloginfo(’pingback_url’);–>: PingBack Url<br>
<!–p bloginfo(’template_url’);–>: 模板文件路径<br>
<!–p bloginfo(’version’);–>: WordPress版本<br>
<!–p bloginfo(’atom_url’);–>: Atom Url<br>
<!–p bloginfo(’rss2_url’);–>: RSS 2.o Url<br>
<!–p bloginfo(’url’);–>: 博客 Url<br>
<!–p bloginfo(’html_type’);–>: 博客网页Html类型<br>
<!–p bloginfo(’charset’);–>: 博客网页编码<br>
<!–p bloginfo(’description’);–>: 博客描述<br>
<!–p wp_title();–>: 特定内容页(Post/Page)的标题</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
<strong>模板PHP函数及命令</strong></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
<!–p get_header();–>: 调用Header模板<br>
<!–p get_sidebar();–>: 调用Sidebar模板<br>
<!–p get_footer();–>: 调用Footer模板<br>
<!–p the_content();–>: 显示内容(Post/Page)<br>
<!–p if(have_posts()) :–>: 检查是否存在Post/Page<br>
<!–p while(have_posts()) : the_post();–>: 如果存在Post/Page则予以显示<br>
<!–p endwhile;–>: While 结束<br>
<!–p endif;–>: If 结束<br>
<!–p the_time(’字符串’)–>: 显示时间,时间格式由“字符串”参数决定,具体参考PHP手册<br>
<!–p comments_popup_link();–>: 正文中的留言链接。如果使用 comments_popup_script() ,则留言会在新窗口中打开,反之,则在当前窗口打开<br>
<!–p the_title();–>: 内容页(Post/Page)标题<br>
<!–p the_permalink()–>: 内容页(Post/Page) Url<br>
<!–p the_category(’,’)–>: 特定内容页(Post/Page)所属Category<br>
<!–p the_author();–>: 作者<br>
<!–p the_ID();–>: 特定内容页(Post/Page) ID<br>
<!–p edit_post_link();–>: 如果用户已登录并具有权限,显示编辑链接<br>
<!–p get_links_list();–>: 显示Blogroll中的链接<br>
<!–p comments_template();–>: 调用留言/回复模板<br>
<!–p wp_list_pages();–>: 显示Page列表<br>
<!–p wp_list_categories();–>: 显示Categories列表<br>
<!–p next_post_link(’%link’);–>: 下一篇文章链接<br>
<!–p previous_post_link(’%link’);–>: 上一篇文章链接<br>
<!–p get_calendar();–>: 日历<br>
<!–p wp_get_archives()–>: 显示内容存档<br>
<!–p posts_nav_link();–>: 导航,显示上一篇/下一篇文章链接<br>
<!–p include(TEMPLATEPATH . ‘/文件名’);–>: 嵌入其他文件,可为定制的模板或其他类型文件</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
<strong>模板相关其他函数</strong></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
<!–p _e(’Message’);–>: 输出相应信息<br>
<!–p wp_register();–>: 显示注册链接<br>
<!–p wp_loginout();–>: 显示登录/注销链接<br>
<!–ext pag–>: 将当前内容分页<br>
<!–or–>: 将当前内容截断,以不在主页/目录页显示全部内容<br>
<!–p timer_stop(1);–>: 网页加载时间(秒)<br>
<!–p echo get_num_queries();–>: 网页加载查询量</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
当然,wordpress的函数远远不止这些,如果你有更高的要求,请访问wordpress官方代码页面.</p>
頁:
[1]