I’ve created something using reverse tags – when something isn’t tagged, it’s flagged up to say “Hey! This post hasn’t been checked yet!”

Now i’m wondering, is there a way to get the last tag created?

Do tags have modified / created dates? Is there a way of getting around this if they haven’t?

The user case I have is security patches for a CMS and I have a team who are documenting everything about it. I want them to create a new tag for the patch, then have a notice display saying “New patch available”

Anyone crossed anything like this before?

1
1

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);

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *