Yoast\WP\SEO\Repositories
Indexable_Hierarchy_Repository::add_ancestor
Adds an ancestor to an indexable.
Метод класса: Indexable_Hierarchy_Repository{}
Хуков нет.
Возвращает
true|false. Whether or not the ancestor was added successfully.
Использование
$Indexable_Hierarchy_Repository = new Indexable_Hierarchy_Repository(); $Indexable_Hierarchy_Repository->add_ancestor( $indexable_id, $ancestor_id, $depth );
- $indexable_id(int) (обязательный)
- The indexable id.
- $ancestor_id(int) (обязательный)
- The ancestor id.
- $depth(int) (обязательный)
- The depth.
Код Indexable_Hierarchy_Repository::add_ancestor() Indexable Hierarchy Repository::add ancestor Yoast 26.5
public function add_ancestor( $indexable_id, $ancestor_id, $depth ) {
if ( ! $this->indexable_helper->should_index_indexables() ) {
return false;
}
$hierarchy = $this->query()->create(
[
'indexable_id' => $indexable_id,
'ancestor_id' => $ancestor_id,
'depth' => $depth,
'blog_id' => \get_current_blog_id(),
]
);
return $hierarchy->save();
}