Yoast\WP\SEO\Repositories

Indexable_Repository::find_all_public_paginated │ public │ Yoast 1.0

Retrieves a paginated set of indexable instances of public indexables.

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

Хуков нет.

Возвращает

Indexable[]. The array with the paginated indexable instances which are public.

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

$Indexable_Repository = new Indexable_Repository();
$Indexable_Repository->find_all_public_paginated( $page, $page_size, $post_type ): array;
$page(int) (обязательный)
The page number (1-based).
$page_size(int) (обязательный)
The number of items per page.
$post_type(строка) (обязательный)
The post type indexables to find.

Код Indexable_Repository::find_all_public_paginated() Yoast 28.9

public function find_all_public_paginated( int $page, int $page_size, string $post_type ): array {
	$offset = ( ( $page - 1 ) * $page_size );

	$query = $this->query()->where_raw( '( is_public IS NULL OR is_public = 1 ) AND ( is_robots_noindex IS NULL OR is_robots_noindex = 0 )' );
	$query->where( 'object_sub_type', $post_type );
	$query->where( 'post_status', 'publish' );

	$indexables = $query->order_by_asc( 'id' )->limit( $page_size )->offset( $offset )->find_many();

	return \array_map( [ $this, 'upgrade_indexable' ], $indexables );
}