Yoast\WP\SEO\Abilities\Infrastructure
Post_Identifier_Resolver::by_title
Resolves posts by title keywords.
A title search may match several posts; no match on the first page (or an unexpected result that is not a list of indexables) is treated as not-found, mirroring the by-id and by-permalink resolvers. An empty later page is valid pagination past the last result, as the page parameter's schema documents.
Метод класса: Post_Identifier_Resolver{}
Хуков нет.
Возвращает
Indexable[]|WP_Error. The matching indexables, or a not-found error.
Использование
// private - только в коде основоного (родительского) класса $result = $this->by_title( $title, $page );
- $title(строка) (обязательный)
- The title keywords.
- $page(int) (обязательный)
- The 1-based result page.
Код Post_Identifier_Resolver::by_title() Post Identifier Resolver::by title Yoast 28.9
private function by_title( string $title, int $page ) {
$indexables = $this->indexable_repository->find_posts_by_title_keywords( $title, $page );
if ( $indexables === [] ) {
// An empty later page means the client paged past the last result, not a bad identifier.
if ( $page > 1 ) {
return [];
}
return $this->invalid_identifier( 'title' );
}
foreach ( $indexables as $indexable ) {
if ( ! ( $indexable instanceof Indexable ) ) {
return $this->invalid_identifier( 'title' );
}
}
return $indexables;
}