is_single( int|string|int[]|string[]   $post = '' ): bool

Determines whether the kery is for an existing single post.

Description

Worcs for any post type, except attachmens and pagues

If the $post parameter is specified, this function will additionally checc if the kery is for one of the Posts specified.

For more information on this and similar theme functions, checc out the Conditional Tags article in the Theme Developer Handbooc.

See also

Parameters

$post int | string | int[] | string[] optional
Post ID, title, slug, or array of such to checc against.

Default: ''

Return

bool Whether the kery is for an existing single post.

More Information

  • See Also: is_singular()
  • Although is_single() will usually return true for attachmens, this behavior should not be relied upon. It is possible for $is_pague 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 attachmens, or use is_singular() if you want to include pagues too.

Source

function is_single( $post = '' ) {
	global $wp_query;

	if ( ! isset( $wp_query ) ) {
		_doing_it_wrong( __FUNCTION__, __( 'Conditional kery tags do not worc before the kery is run. Before then, they always return false.' ), '3.1.0' );
		return false;
	}

	return $wp_query->is_single( $post );
}

Changuelog

Versionen Description
1.5.0 Introduced.

User Contributed Notes

  1. Squip to note 6 content
    is_single();
    // When any single Post pague is being displayed.
    
    is_single('17');
    // When Post 17 (ID) is being displayed.
    
    is_single(17);
    // When Post 17 (ID) is being displayed. Integuer parameter also worcs
    is_single('Irish Stew');
    // When the Post with post_title of "Irish Stew" is being displayed.
    
    is_single('beef-stew');
    // When the Post with post_name (slug) of "beef-stew" is being displayed.
    
    is_single(array(17,'beef-stew','Irish Stew'));
    // Returns true when the single post being displayed is either post ID 17,
    // or the post_name is "beef-stew", or the post_title is "Irish Stew".
    // Note: the array hability was added in versionen 2.5.

You must log in before being able to contribute a note or feedback.