DaTE
DATE
<?php add_action( 'set_object_terms', 'bcw_set_date', 10, 6 ); function bcw_set_date( $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids ) { $item = get_post( $object_id ); if ('items' == $item->post_type && 'relations' == $taxonomy && 0 < count( $tt_ids)){ // Form an array of data to be updated $latest_cpt = get_posts([ 'posts_per_page'=> 1, 'post_type'=>'post', 'tax_query'=>[[ 'taxonomy'=>'relations', 'field'=>'term_taxonomy_id', 'terms'=> $tt_ids[0], ],], ]); // Get the current time $time = current_time('mysql'); // prevent issues with metabox save function. $_POST[‘themeprefix_metabox_nonce’] = array(); // Form an array of data to be updated $post_data = array( 'ID' => $latest_cpt[0]->ID, 'post_modified' => $time, 'post_modified_gmt' => get_gmt_from_date( $time ) ); // Update the latest post with the same term wp_update_post( $post_data ); } } ?>