We can use is_single() Conditional Tag to detect the single post page.
Syntax
is_single( int|string|int[]|string[] $post = '' )
This functions determines whether the query is for an existing single post and checks for any post type, except attachments and pages.
As you can see in the syntax, we can pass the $post parameter and this function will additionally check if the query is for one of the Posts specified.
We can pass post ID, title, slug, or array of such as parameter to this function.
👉 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.
Examples
is_single();
// When any single Post page is being displayed.
is_single('1');
// When Post 1 (ID) is being displayed.
is_single(1);
// When Post 1 (ID) is being displayed.
// Integer parameter also works => is_single('How to check if the page is single post page in WordPress?');
// When the Post with post_title of "How to check if the page is single post page in WordPress?" is being displayed.
is_single('how-to-check-if-the-page-is-single-post-page-in-wordpress');
// When the Post with post_name (slug) of "how-to-check-if-the-page-is-single-post-page-in-wordpress" is being displayed.
is_single(array(1,'how-to-check-if-the-page-is-single-post-page-in-wordpress','Irish Stew'));
// Returns true when the single post being displayed is either post ID 1,
// or the post_name is "how-to-check-if-the-page-is-single-post-page-in-wordpress", or the post_title is "How to check if the page is single post page in WordPress?".
is_single( array( 17, 19, 1, 11 ) )
Returns true when the single post being displayed is either post ID = 17, post ID = 19, post ID = 1 or post ID = 11.
is_single( array( 'slug-1', 'slug-2', 'slug-3' ) )
Returns true when the single post being displayed is either the post_name "slug-1", post_name "slug-2" or post_name "slug-3".
is_single( array( 'Title 1', 'Title 2', 'Title 3' ) )
Returns true when the single post being displayed is either the post_title is "Title 1", post_title is "Title 2" or post_title is "Title 3".
Credit: WordPress Dev
conditional examples functions is_single single-page tags