Yoast\WP\SEO\Repositories

Indexable_Repository::get_subpages_by_post_parent()publicYoast 1.0

Returns all subpages with a given post_parent.

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

Хуков нет.

Возвращает

Indexable[]. array of indexables.

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

$Indexable_Repository = new Indexable_Repository();
$Indexable_Repository->get_subpages_by_post_parent( $post_parent, $exclude_ids );
$post_parent(int) (обязательный)
The post parent.
$exclude_ids(массив)
The id's to exclude.
По умолчанию: []

Код Indexable_Repository::get_subpages_by_post_parent() Yoast 22.4

public function get_subpages_by_post_parent( $post_parent, $exclude_ids = [] ) {
	$query = $this->query()
		->where( 'post_parent', $post_parent )
		->where( 'object_type', 'post' )
		->where( 'post_status', 'publish' );

	if ( ! empty( $exclude_ids ) ) {
		$query->where_not_in( 'object_id', $exclude_ids );
	}
	return $query->find_many();
}