BC Migration Documentation

Taxonomies

AbstractYes

Taxonomies Class

Table of Contents

Methods

get_by_post_type()  : array<string|int, string>
Retrieves the taxonomies associated with the given post type.
get_terms()  : array<string|int, string>|WP_Error
Retrieve terms from a taxonomy.
rename()  : array{term_id: int, term_taxonomy_id: int}|WP_Error
Rename a taxonomy term by slug or name.

Methods

get_by_post_type()

Retrieves the taxonomies associated with the given post type.

public get_by_post_type([string $post_type = '' ]) : array<string|int, string>
Parameters
$post_type : string = ''

Optional. Post type to retrieve taxonomies for.

Return values
array<string|int, string>

Array of taxonomy names.

get_terms()

Retrieve terms from a taxonomy.

public get_terms([string $term = '' ]) : array<string|int, string>|WP_Error
Parameters
$term : string = ''

Optional. Term name or slug to search for.

Return values
array<string|int, string>|WP_Error

The terms data or WP_Error on failure.

rename()

Rename a taxonomy term by slug or name.

public rename(string $taxonomy, string $old_term, string $new_name[, string|null $new_slug = null ]) : array{term_id: int, term_taxonomy_id: int}|WP_Error
Parameters
$taxonomy : string

The taxonomy slug (e.g., 'category', 'industries').

$old_term : string

The current term name or slug to search for.

$new_name : string

The new name you want to assign.

$new_slug : string|null = null

(Optional) New slug for the term.

Return values
array{term_id: int, term_taxonomy_id: int}|WP_Error

The updated term data or WP_Error on failure.


        
On this page

Search results