wordpress主题函数基础大全

1、基本条件判断函数:

is_home() //是否为主页
is_single() //是否为内容页 (Post)
is_page() //是否为内容页 (Page)
is_category() //是否为 Category/Archive 页
is_tag() //是否为标签 (Tag) 存档页
is_date() //是否为指定日期存档页
is_year() //是否为指定年份存档页
is_month() //是否为指定月份存档页
is_day() //是否为指定日存档页
is_time() //是否为指定时间存档页
is_archive() //是否为存档页
is_search() //是否为搜索结果页
is_404() //是否为 "HTTP 404: Not Found" 错误页
is_paged() //主页 /Category/Archive 页是否以多页显示

2、Header部分常用到的PHP函数:

<?phpbloginfo('name');?>//博客名称(Title)
<?phpbloginfo('stylesheet_url');?>//CSS文件路径
<?phpbloginfo('pingback_url');?>//PingBackURL
<?phpbloginfo('template_url');?>//模板文件路径
<?phpbloginfo('version');?>//WordPress版本
<?phpbloginfo('atom_url');?>//AtomURL
<?phpbloginfo('rss2_url');?>//RSS2.oURL
<?phpbloginfo('url');?>//博客URL
<?phpbloginfo('html_type');?>//博客网页HTML类型
<?phpbloginfo('charset');?>//博客网页编码
<?phpbloginfo('description');?>//博客描述
<?phpwp_title();?>//特定内容页(Post/Page)的标题

3、模板常用的PHP函数及命令:

<?phpget_header();?>//调用Header(头部)模板
<?phpget_sidebar();?>//调用Sidebar(边栏)模板
<?phpget_footer();?>//调用Footer(底部)模板
<?phpthe_content();?>//显示内容(Post/Page)
<?phpif(have_posts()):?>//检查是否存在Post/Page
<?phpwhile(have_posts()):the_post();?>//如果存在Post/Page则予以显示
<?phpendwhile;?>//While结束
<?phpendif;?>//If结束
<?phpthe_time('字符串')?>//显示时间,时间格式由"字符串"参数决定,具体参考PHP手册
<?phpcomments_popup_link();?>//正文中的留言链接,如果使用comments_popup_script();则新窗口打开链接
<?phpthe_title();?>//内容页(Post/Page)标题
<?phpthe_permalink()?>//内容页(Post/Page)URL
<?phpthe_category(',')?>//特定内容页(Post/Page)所属Category
<?phpthe_author();?>//作者
<?phpthe_ID();?>//特定内容页(Post/Page)ID
<?phpedit_post_link();?>//如果用户已登录并具有权限,显示编辑链接
<?phpget_links_list();?>//显示Blogroll中的链接
<?phpcomments_template();?>//调用留言/回复模板
<?phpwp_list_pages();?>//显示Page列表
<?phpwp_list_categories();?>//显示Categories列表
<?phpnext_post_link('%link');?>//下一篇文章链接
<?phpprevious_post_link('%link');?>//上一篇文章链接
<?phpget_calendar();?>//日历
<?phpwp_get_archives()?>//显示内容存档
<?phpposts_nav_link();?>//导航,显示上一篇/下一篇文章链接
<?phpinclude(TEMPLATEPATH.'/文件名');?>//嵌入其他文件,可为定制的模板或其他类型文件

4、与模板相关的其它函数:

<?php_e('Message');?>//输出相应信息
<?phpwp_register();?>//显示注册链接
<?phpwp_loginout();?>//显示登录/注销链接
<!–nextpage–>//将当前内容分页
<!–more–>//将当前内容截断,以不在主页/目录页显示全部内容
<?phptimer_stop(1);?>//网页加载时间(秒)
<?phpechoget_num_queries();?>//网页加载查询量

👋 感谢您的观看!

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享