is_single()
is_single( int|string|int[]|string[] $post = ” ) 确定查询是否…
is_single( int|string|int[]|string[] $post = ” )
确定查询是否针对现有的单个日志。
Determines whether the query is for an existing single post.
目录锚点:#说明#参数#返回#源码
说明(Description)
另见函数 is_page()
参数(Parameters)
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| $post | (int | string | int[] | string[]) | 可选 | 投递ID,标题,弹头,或一系列这样的东西来核对。 |
返回(Return)
(bool)查询是否针对现有的单个post。
源码(Source)
/**
* Is the query for an existing single post?
*
* Works for any post type, except attachments and pages
*
* If the $post parameter is specified, this function will additionally
* check if the query is for one of the Posts specified.
*
* @see is_page()
* @see is_singular()
*
* @since 1.5.0
*
* @global WP_Query $wp_query
*
* @param mixed $post Post ID, title, slug, or array of such.
* @return bool
*/
function is_single( $post = '' ) {
global $wp_query;
if ( ! isset( $wp_query ) ) {
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
return false;
}
return $wp_query->is_single( $post );
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 1.5.0 | wp-includes/query.php:722 | 10 | 3 |
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

还没有任何评论,赶紧来占个楼吧!