WPSEO_Post_Type_Sitemap_Provider::get_post_type_archive_link()protectedYoast 5.3

Get URL for a post type archive.

Метод класса: WPSEO_Post_Type_Sitemap_Provider{}

Хуков нет.

Возвращает

Строку|true|false. URL or false if it should be excluded.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_post_type_archive_link( $post_type );
$post_type(строка) (обязательный)
Post type.

Список изменений

С версии 5.3 Введена.

Код WPSEO_Post_Type_Sitemap_Provider::get_post_type_archive_link() Yoast 22.4

protected function get_post_type_archive_link( $post_type ) {

	$pt_archive_page_id = -1;

	if ( $post_type === 'post' ) {

		if ( get_option( 'show_on_front' ) === 'posts' ) {
			return YoastSEO()->helpers->url->home();
		}

		$pt_archive_page_id = (int) get_option( 'page_for_posts' );

		// Post archive should be excluded if posts page isn't set.
		if ( $pt_archive_page_id <= 0 ) {
			return false;
		}
	}

	if ( ! $this->is_post_type_archive_indexable( $post_type, $pt_archive_page_id ) ) {
		return false;
	}

	return get_post_type_archive_link( $post_type );
}