标题 | wordpress模板页面判断函数 |
内容 | 自己平时用到的一些函数,整理一下,大家有用到来拿吧,我怕放电脑上不见了,以后又得找。 index page 首页 is_home() 判断是否为首页. the front page 首页头版消息设置 is_front_page() 判 断是否为首页头版消息. (无论是日志或是页面).当系统显示博客主页且管理面板的设置>阅读菜单下 “主页显示为”选项设为最近发表的文章”,或者’设置>阅读菜单下”主页显示为”选项设为且”主页”是当前被显示的页面 时,is_front_page() 标签返回true。 the administration panels 管理控制面板 is_admin() 判断是否为后台管理控制面板. a single post page 单篇日志 is_single() 判断是否为任何单篇日志. is_single(’17′) 判断是否为id17的单篇日志. is_single(‘irish stew’) 判断是否标题为”irish stew”的单篇日志. is_single(‘beef-stew’) 判断是否别名为 “beef-stew”的单篇日志. is_single(array(17,’beef-stew’,’irish stew’)) 判断是否为id17, 或别名为”beef-stew”, 或标题为 “irish stew”的单篇日志. is_single(array(17, 19, 1, 11)) 判断是否为id 17, 19, 1, 11 的文章. is_single(array(‘beef-stew’, ‘pea-soup’, ‘chili’)) 判断是否别名为 “beef-stew”, 别名为 “pea-soup” 或 别名为 “chili” 的单篇日志. is_single(array(‘beef stew’, ‘pea soup’, ‘chili’)) 判断是否标题为 “beef stew”,标题为 “pea soup” 或标题为 “chili” 的单篇日志. a sticky post 置顶文章 is_sticky() 判断是否为置顶文章. is_sticky(’17′) 判断是否为id17的置顶文章. a comments popup 评论的弹出窗口 is_comments_popup() 判断是否为评论的弹出窗口. any page containing posts 评论 comments_open() 判断当前文章是否允许评论. pings_open() 判断当前文章是否允许广播(pingback). a page page 页面 is_page() 判断是否任何页面. is_page(’42′) 判断是否id 42的页面. is_page(‘about me and joe’) 判断是否标题为”about me and joe” 的页面. is_page(‘about-me’) 判断是否别名为 “about-me” 的页面. is_page(array(42,’about-me’,’about me and joe’)) 判断是否为 id 42, 或别名 “about-me”, 或标题 “about me and joe” 的页面. a category page 分类归档 is_category() 判断是否为任何分类页. is_category(’9′) 判断是否为id9的分类页. is_category(‘stinky cheeses’) 判断是否名称为 “stinky cheeses”的分类归档页. is_category(‘blue-cheese’) 判断别名是否为 “blue-cheese”的分类归档页. is_category(array(9,’blue-cheese’,’stinky cheeses’)) 判断是否id为 9, 或者别名为 “blue-cheese”, 或者名称为 “stinky cheeses”的分类归档页. in_category(’5′) 判断当前文章的分类id是否为5 in_category( array( 1,2,3 ) ) 判断当前文章的分类id是否为 1, 2, 或 3. !in_category( array( 4,5,6 ) ) 判断当前文章的分类id是否不是 4, 5, 或 6 . a tag page 标签归档 is_tag() 判断是否为标签页 is_tag(‘mild’) 判断是否为别名 ‘mild’ 的标签归档页. is_tag(array(‘sharp’,’mild’,’extreme’)) 判断别名是否为 “sharp”, “mild”, 或 “extreme” 的标签归档页. has_tag() 判断当前文章是否有标签. has_tag(‘mild’) 判断当前文章是否有标签 ‘mild’. has_tag(array(‘sharp’,’mild’,’extreme’)) 判断当前文章是否包含一个数组中的标签. an author page 作者归档 is_author() 判断是否为作者归档页. is_author(’4′) 判断是否为id4的作者归档页. is_author(‘vivian’) 判断是否为昵称 “vivian”的作者归档页. is_author(‘john-jones’) 判断是否为昵称 “john-jones” 的作者归档页. is_author(array(4,’john-jones’,’vivian’)) 判断是否为 id 4, 或者昵称 “john-jones”, 或昵称 “vivian” 的作者标签页. a date page 日期归档页 is_date() 判断是否为日期归档页. is_year() 判断是否为按年归档页. is_month() when a monthly archive is being displayed. is_day() 判断是否为按天归档页. is_time() 判断是否按小时, “分钟”, “秒”归档页. any archive page 归档页 is_archive() 是否归档页. a search result page 搜索结果页 is_search() 是否搜索页. a 404 not found page 未找到页面 is_404() 是否404页面. a paged page 分页 is_paged() 判断是否有分页. 需要将 <!–nextpage–> 快速标签插入到文章中才能将文章分成多页. an attachment 附件 is_attachment() 判断是否为附件文档. 附件是通过编辑器上传工具上传的图片或其他文件. 附件能显示在相应的页面或模版中. a single page, single post or attachment 独立页面、单篇日志或附件 is_feed() 网站需要使用rss订阅时,is_feed()返回true。一般情况下会用到is_feed()标签的是wordpress系统和插件开发人员,普通 wordpress用户很少用到is_feed()标签. a trackback 引用通知 is_trackback() 网站需要将wordpress钩子勾入trackback。一般情况下会用到这个标签的是wordpress系统和插件开发人员,普通wordpress 用户很少用到is_feed()标签. a preview 草稿预览 is_preview() 判断文章是否显示在草稿预览模式. has an excerpt 摘要 has_excerpt() 判断当前文章是否有摘要. has_excerpt(’42′) 判断id42的文章是否有摘要. inside the loop 循环 in_the_loop() 判断目前是否在wordpress主循环中. 该标签适用于插件开发人员, 若目前在wordpress主循环中, 该标签返回true. is sidebar active 边栏 is_active_sidebar() 检查现有侧边栏是否被激活(是否启用).若侧边栏被启用,is_active_sidebar() 返回true,否则返回false. |
随便看 |
|
在线学习网考试资料包含高考、自考、专升本考试、人事考试、公务员考试、大学生村官考试、特岗教师招聘考试、事业单位招聘考试、企业人才招聘、银行招聘、教师招聘、农村信用社招聘、各类资格证书考试等各类考试资料。