Yoast\WP\SEO\Llms_Txt\Infrastructure\Content

Automatic_Post_Collection::get_postspublicYoast 1.0

Gets the posts that are relevant for the LLMs.txt.

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

Хуков нет.

Возвращает

Массив. array<Content_Type_Entry>> The posts that are relevant for the LLMs.txt.

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

$Automatic_Post_Collection = new Automatic_Post_Collection();
$Automatic_Post_Collection->get_posts( $post_type, $limit ): array;
$post_type(строка) (обязательный)
The post type.
$limit(int) (обязательный)
The maximum number of posts to return.

Код Automatic_Post_Collection::get_posts() Yoast 26.9

public function get_posts( string $post_type, int $limit ): array {
	$posts = $this->get_recent_cornerstone_content( $post_type, $limit );

	if ( \count( $posts ) >= $limit ) {
		return $posts;
	}

	$recent_posts = $this->get_recent_posts( $post_type, $limit );
	foreach ( $recent_posts as $recent_post ) {
		// If the post is already in the list because it's cornerstone, don't add it again.
		if ( isset( $posts[ $recent_post->get_id() ] ) ) {
			continue;
		}

		$posts[ $recent_post->get_id() ] = $recent_post;

		if ( \count( $posts ) >= $limit ) {
			break;
		}
	}

	return $posts;
}