Yoast\WP\SEO\Repositories
Indexable_Repository::get_recently_modified_posts
Returns most recently modified posts of a post type.
Метод класса: Indexable_Repository{}
Хуков нет.
Возвращает
Indexable[]. array of indexables.
Использование
$Indexable_Repository = new Indexable_Repository(); $Indexable_Repository->get_recently_modified_posts( $post_type, $limit, $exclude_older_than_one_year, $search_filter );
- $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(строка)
- A search filter to apply to the breadcrumb title.
По умолчанию:''
Код Indexable_Repository::get_recently_modified_posts() Indexable Repository::get recently modified posts Yoast 28.7
public function get_recently_modified_posts( string $post_type, int $limit, bool $exclude_older_than_one_year, string $search_filter = '' ) {
$query = $this->query()
->where( 'object_type', 'post' )
->where( 'object_sub_type', $post_type )
->where_raw( '( is_public IS NULL OR is_public = 1 )' )
->order_by_desc( 'object_last_modified' )
->limit( $limit );
if ( $exclude_older_than_one_year === true ) {
$query->where_gte( 'object_published_at', \gmdate( 'Y-m-d H:i:s', \strtotime( '-1 year' ) ) );
}
if ( $search_filter !== '' ) {
$query->where_like( 'breadcrumb_title', '%' . $search_filter . '%' );
}
$query->order_by_desc( 'object_last_modified' )
->limit( $limit );
return $query->find_many();
}