Home  >  Article  >  Backend Development  >  Introduction to is_singular() function in WordPress, wordpress function manual_PHP tutorial

Introduction to is_singular() function in WordPress, wordpress function manual_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:08:001078browse

Introduction to is_singular() function in WordPress, wordpress function manual

The function is_singular() detects true when one of the following returns true: is_single(), is_page(), is_attachment(). If $post_types is specified, it is also necessary to check whether it is of this type.

Function prototype

Copy code The code is as follows:

is_singular( $post_types = '' );

Detailed explanation of parameters
$post_types, Post type or the type in the current query.
Return value
Returns true if the detection is successful, otherwise returns false.

Application examples
Display different advertisements under the singular page:

Copy code The code is as follows:

if( is_singular()){
// show adv. #1
} else {
// show adv. #2
}
?>

Returns true for normal posts:

Copy code The code is as follows:

is_singular('post');

If is_single(), is_page(), is_attachement() returns true, the following function returns true:

Copy code The code is as follows:

is_singular();

For custom post type book, the following function returns true:

Copy code The code is as follows:

is_singular('book');

Summary

When using paging navigation, the navigation is not displayed when is_singular().

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/954098.htmlTechArticleIntroduction to the is_singular() function in WordPress, wordpress function manual function is_singular() detection result is true, when one of the following When true is returned: is_single(), is_page(), is_attachment(). Such as...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn