Random WordPress Function

Learn about a new WordPress function every day!


Function Signature:

unregister_term_meta

Function Description:

Unregisters a meta key for terms.

Function Examples:

⚠️ Examples below are generated with GPT-3 once every hour. Do not take them too seriously.
Consider them as some extra input in your learning process - reason about them. Will it work? What could fail?
// Example 1: Unregistering a specific term meta field for a custom taxonomy
unregister_term_meta( 10, 'genre', 'featured_genre' );
// Example 2: Unregistering all term meta fields for a specific term in a taxonomy
$term_id = 20;
$taxonomy = 'category';
$term_meta = get_term_meta( $term_id );
foreach ( $term_meta as $key => $value ) {
    unregister_term_meta( $term_id, $taxonomy, $key );
}
// Example 3: Unregistering term meta fields for all terms in a specific taxonomy
$taxonomy = 'post_tag';
$terms = get_terms( array( 'taxonomy' => $taxonomy, 'hide_empty' => false ) );
foreach ( $terms as $term ) {
    $term_meta = get_term_meta( $term->term_id );
    foreach ( $term_meta as $key => $value ) {
        unregister_term_meta( $term->term_id, $taxonomy, $key );
    }
}