Yoast\WP\SEO\Llms_Txt\Infrastructure\Content
Automatic_Post_Collection::get_recently_modified_posts_wp_query
Returns most recently modified posts of a post type, using WP_Query.
Метод класса: Automatic_Post_Collection{}
Хуков нет.
Возвращает
Массив
Использование
// private - только в коде основоного (родительского) класса $result = $this->get_recently_modified_posts_wp_query( $post_type, $limit, $exclude_older_than_one_year, $search_filter ): array;
- $post_type(строка) (обязательный)
- The post type.
- $limit(int) (обязательный)
- The maximum number of posts to return.
- $exclude_older_than_one_year(true|false) (обязательный)
- Whether to exclude posts older than one year.
- $search_filter(строка)
- The search filter to apply to the query.
По умолчанию:''
Код Automatic_Post_Collection::get_recently_modified_posts_wp_query() Automatic Post Collection::get recently modified posts wp query Yoast 27.7
private function get_recently_modified_posts_wp_query( string $post_type, int $limit, bool $exclude_older_than_one_year, string $search_filter = '' ): array {
$args = [
'post_type' => $post_type,
'posts_per_page' => $limit,
'post_status' => 'publish',
'orderby' => 'modified',
'order' => 'DESC',
'has_password' => false,
];
if ( $exclude_older_than_one_year === true ) {
$args['date_query'] = [
[
'after' => '12 months ago',
],
];
}
if ( $search_filter !== '' ) {
$args['s'] = $search_filter;
}
$posts = [];
foreach ( \get_posts( $args ) as $post ) {
$posts[] = Content_Type_Entry::from_post( $post, \get_permalink( $post->ID ) );
}
return $posts;
}