Yoast\WP\SEO\Llms_Txt\Infrastructure\Content

Automatic_Post_Collection::get_recent_postspublicYoast 1.0

Gets the most recently modified posts.

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

Хуков нет.

Возвращает

Массив. The most recently modified posts.

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

$Automatic_Post_Collection = new Automatic_Post_Collection();
$Automatic_Post_Collection->get_recent_posts( $post_type, $limit, $search_filter, $disable_excluding_old_posts ): array;
$post_type(строка) (обязательный)
The post type.
$limit(int) (обязательный)
The maximum number of posts to return.
$search_filter(строка)
The search filter to apply to the query.
По умолчанию: ''
$disable_excluding_old_posts(true|false)
Whether to disable excluding posts older than one year.
По умолчанию: false

Код Automatic_Post_Collection::get_recent_posts() Yoast 27.7

public function get_recent_posts( string $post_type, int $limit, string $search_filter = '', bool $disable_excluding_old_posts = false ): array {
	$exclude_older_than_one_year = false;

	if ( $post_type === 'post' && ! $disable_excluding_old_posts ) {
		$exclude_older_than_one_year = true;
	}

	if ( $this->indexable_helper->should_index_indexables() ) {
		return $this->get_recently_modified_posts_indexables( $post_type, $limit, $exclude_older_than_one_year, $search_filter );
	}

	return $this->get_recently_modified_posts_wp_query( $post_type, $limit, $exclude_older_than_one_year, $search_filter );
}