The global_terms WordPress PHP function maintains a canonical list of terms by syncing terms created for each blog with the global terms table.
Usage
global_terms($term_id, $deprecated = '');
Parameters
$term_id(int) – Required: An ID for a term on the current blog.$deprecated(string) – Optional: Not used. Default: ”.
More information
See WordPress Developer Resources: global_terms
Examples
Syncing a term
This example syncs a term with the ID of 10 to the global terms table.
$term_id = 10; global_terms($term_id);
Syncing a term with deprecated parameter
This example syncs a term with the ID of 15 to the global terms table and includes the deprecated parameter.
$term_id = 15; $deprecated = 'Deprecated'; global_terms($term_id, $deprecated);
Syncing a term after creating a new category
This example creates a new category and syncs the created term to the global terms table.
$new_category = wp_create_category('New Category');
global_terms($new_category);
Syncing a term after creating a new tag
This example creates a new tag and syncs the created term to the global terms table.
$new_tag = wp_create_tag('New Tag');
if (!is_wp_error($new_tag)) {
global_terms($new_tag['term_id']);
}
Syncing a term after updating a category
This example updates a category’s name and syncs the term to the global terms table.
$term_id = 25;
$updated_category = wp_update_term($term_id, 'category', array('name' => 'Updated Category'));
if (!is_wp_error($updated_category)) {
global_terms($term_id);
}