BlogTaxonomies
extends Taxonomies
in package
BlogTaxonomies class
Table of Contents
Properties
- $taxonomies : array<string|int, string>
- The taxonomies associated with the 'blog' post type.
- $instance : BlogTaxonomies|null
- The single instance of the class.
Methods
- __construct() : mixed
- Constructor.
- 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.
- init() : BlogTaxonomies
- Gets the single instance of the class.
- rename() : array{term_id: int, term_taxonomy_id: int}|WP_Error
- Rename a taxonomy term by slug or name.
- taxonomies() : array<string|int, string>
- Get the taxonomies associated with the 'blog' post type.
Properties
$taxonomies
The taxonomies associated with the 'blog' post type.
public
array<string|int, string>
$taxonomies
$instance
The single instance of the class.
protected
static BlogTaxonomies|null
$instance
= null
Methods
__construct()
Constructor.
public
__construct() : mixed
Initializes the BlogTaxonomies class by fetching taxonomies related to the 'blog' post type and calling the parent constructor.
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.
init()
Gets the single instance of the class.
public
static init() : BlogTaxonomies
Return values
BlogTaxonomies —Single instance of the class.
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.
taxonomies()
Get the taxonomies associated with the 'blog' post type.
public
taxonomies() : array<string|int, string>
Return values
array<string|int, string> —The taxonomies associated with the 'blog' post type.