以下是@PieterGoosen(信用到期)的思路:
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\');
现在可以通过以下方式访问元数据:
//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);