is_single()判断当前页面类型是否为文章页

目录

描述

This conditional tag checks if a single post of any post type (except attachment and page post types) is being displayed. If the $post parameter is specified, the function will additionally check if the query is for one of the posts specified. To check for all the post types, use the is_singular() function.

is_single() 描述

用法

<?php is_single($post); ?>

is_single() 用法

参数

$post

(mixed) (可选) Post ID, Post Title, Post Slug, or array of posts (WP 2.5+)

默认值: None

is_single() 参数

返回值

(boolean

True on success, false on failure.

is_single() 返回值

示例

is_single() 示例

注意

  • See Also: is_singular()
  • Although is_single() will usually return true for attachments, this behavior should not be relied upon. It is possible for $is_page and $is_attachment to be true at the same time, and in that case $is_single will be false. For this reason, you should use is_attachment() || is_single() if you want to include attachments, or use is_singular() if you want to include pages too. See ticket #14034 for more information.

is_single() 注意

历史

添加于 版本: 1.5.0

is_single() 历史

源文件

is_single() 函数的代码位于 wp-includes/query.php.

is_single() 源文件

相关