Yoast\WP\SEO\Repositories

Indexable_Hierarchy_Repository::add_ancestor()publicYoast 1.0

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() Yoast 22.3

public function add_ancestor( $indexable_id, $ancestor_id, $depth ) {
	$hierarchy = $this->query()->create(
		[
			'indexable_id' => $indexable_id,
			'ancestor_id'  => $ancestor_id,
			'depth'        => $depth,
			'blog_id'      => \get_current_blog_id(),
		]
	);

	return $hierarchy->save();
}