Determines whether the query is for an existing single post.
Description
Works for any post type excluding pages.
If the $post parameter is specified, this function will additionally check if the query is for one of the Posts specified.
See also
Parameters
$post
int|string|int[]|string[]optional- Post ID, title, slug, path, or array of such to check against.
Default:
''
Source
return false;
}
$page = array_map( 'strval', (array) $page );
if ( in_array( (string) $page_obj->ID, $page, true ) ) {
return true;
} elseif ( in_array( $page_obj->post_title, $page, true ) ) {
return true;
} elseif ( in_array( $page_obj->post_name, $page, true ) ) {
return true;
} else {
foreach ( $page as $pagepath ) {
if ( ! strpos( $pagepath, '/' ) ) {
continue;
}
$pagepath_obj = get_page_by_path( $pagepath );
if ( $pagepath_obj && ( $pagepath_obj->ID === $page_obj->ID ) ) {
return true;
}
}
}
return false;
}
/**
* Determines whether the query is for a paged result and not for the first page.
*
* @since 3.1.0
*
* @return bool Whether the query is for a paged result.
*/
public function is_paged() {
Changelog
Version | Description |
---|---|
3.1.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.