WPSEO_Post_Type_Sitemap_Provider::get_excluded_posts
Retrieves a list with the excluded post ids.
Метод класса: WPSEO_Post_Type_Sitemap_Provider{}
Хуки из метода
Возвращает
Массив. Array with post ids to exclude.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_excluded_posts( $post_type );
- $post_type(строка) (обязательный)
- Post type.
Код WPSEO_Post_Type_Sitemap_Provider::get_excluded_posts() WPSEO Post Type Sitemap Provider::get excluded posts Yoast 27.6
protected function get_excluded_posts( $post_type ) {
$excluded_posts_ids = [];
$page_on_front_id = ( $post_type === 'page' ) ? (int) get_option( 'page_on_front' ) : 0;
if ( $page_on_front_id > 0 ) {
$excluded_posts_ids[] = $page_on_front_id;
}
/**
* Filter: 'wpseo_exclude_from_sitemap_by_post_ids' - Allow extending and modifying the posts to exclude.
*
* @param array $posts_to_exclude The posts to exclude.
*/
$excluded_posts_ids = apply_filters( 'wpseo_exclude_from_sitemap_by_post_ids', $excluded_posts_ids );
if ( ! is_array( $excluded_posts_ids ) ) {
$excluded_posts_ids = [];
}
$excluded_posts_ids = array_map( 'intval', $excluded_posts_ids );
$page_for_posts_id = ( $post_type === 'page' ) ? (int) get_option( 'page_for_posts' ) : 0;
if ( $page_for_posts_id > 0 ) {
$excluded_posts_ids[] = $page_for_posts_id;
}
return array_unique( $excluded_posts_ids );
}