WP_Term
is a class in WordPress that represents terms within taxonomies such as categories, tags, or custom taxonomies.
- term_id: The ID of the term.
- name: The name of the term.
- slug: The slug of the term, used in URLs.
- term_group: The group that the term belongs to.
- term_taxonomy_id: The ID of the term in the term_taxonomy table.
- taxonomy: The taxonomy of the term (e.g., category, post_tag).
- description: The description of the term.
- parent: The ID of the parent term (for hierarchical taxonomies).
- count: The number of posts associated with the term.
- get_term(): Retrieves a term given its ID and taxonomy.
- get_terms(): Retrieves terms in a given taxonomy or list of taxonomies.
- wp_insert_term(): Adds a new term to the database.
- wp_update_term(): Updates a term in the database.
- wp_delete_term(): Removes a term from the database.
$categories = get_terms(array(
'taxonomy' => 'category',
'hide_empty' => false,
));
foreach ($categories as $category) {
echo $category->name;
}