Yoast\WP\SEO\Builders
Primary_Term_Builder::save_primary_term()
Save the primary term for a specific taxonomy.
Метод класса: Primary_Term_Builder{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->save_primary_term( $post_id, $taxonomy );
- $post_id(int) (обязательный)
- Post ID to save primary term for.
- $taxonomy(строка) (обязательный)
- Taxonomy to save primary term for.
Код Primary_Term_Builder::save_primary_term() Primary Term Builder::save primary term Yoast 25.0
protected function save_primary_term( $post_id, $taxonomy ) { $term_id = $this->meta->get_value( 'primary_' . $taxonomy, $post_id ); $term_selected = ! empty( $term_id ); $primary_term_indexable = $this->repository->find_by_post_id_and_taxonomy( $post_id, $taxonomy, $term_selected ); // Removes the indexable when no term found. if ( ! $term_selected ) { if ( $primary_term_indexable ) { $primary_term_indexable->delete(); } return; } $primary_term_indexable->term_id = $term_id; $primary_term_indexable->post_id = $post_id; $primary_term_indexable->taxonomy = $taxonomy; $primary_term_indexable->blog_id = \get_current_blog_id(); $this->indexable_helper->save_indexable( $primary_term_indexable ); }