Yoast\WP\SEO\Llms_Txt\Infrastructure\Content
Automatic_Post_Collection::get_posts
Gets the posts that are relevant for the LLMs.txt.
Метод класса: Automatic_Post_Collection{}
Хуков нет.
Возвращает
Массив
Использование
$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() 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;
}