Do tags have dates?

Following @PieterGoosen’s (credit due) train of thought hook onto the following:

function update_term_timestamps($term_id) {

    switch( current_filter() ) {
        case 'created_term':
            update_term_meta($term_id, '_term_created_at', current_time('mysql', true));
        break;
        case 'edited_term':
            update_term_meta($term_id, '_term_edited_at', current_time('mysql', true));
        break;
    }

}

add_action('created_term', 'update_term_timestamps');
add_action('edited_term', 'update_term_timestamps');

Now the meta data is accessible with:

//for created timestamp...
$timestamp = get_term_meta($term_id, '_term_created_at', true);

//for edited timestamp...
$timestamp = get_term_meta($term_id, '_term_edited_at', true);

Leave a Comment