Yoast\WP\SEO\Helpers
Post_Helper::is_post_indexable
Determines if the post can be indexed.
Метод класса: Post_Helper{}
Хуков нет.
Возвращает
true|false. True if the post can be indexed.
Использование
$Post_Helper = new Post_Helper(); $Post_Helper->is_post_indexable( $post_id );
- $post_id(int) (обязательный)
- Post ID to check.
Код Post_Helper::is_post_indexable() Post Helper::is post indexable Yoast 27.6
public function is_post_indexable( $post_id ) {
// Don't index posts which are not public (i.e. viewable).
$post_type = \get_post_type( $post_id );
if ( ! $this->post_type->is_of_indexable_post_type( $post_type ) ) {
return false;
}
// Don't index excluded post statuses.
if ( \in_array( \get_post_status( $post_id ), $this->get_excluded_post_statuses(), true ) ) {
return false;
}
// Don't index revisions of posts.
if ( \wp_is_post_revision( $post_id ) ) {
return false;
}
// Don't index autosaves that are not caught by the auto-draft check.
if ( \wp_is_post_autosave( $post_id ) ) {
return false;
}
return true;
}