I am trying to do something similar to this block of code - but with tax terms rather than custom fields in a post
its a bit beyond me
/**
Add an auto-incrementing Project ID field to Design feedback posts */ function auto_assign_ids( $post_id, $post, $update ) {
// Only assign ID to new design posts if ( $post->post_status == 'publish' && $post->post_type == 'designapprovalsystem' ) {
// get the most recent Project post $project_args = array( 'numberposts' => 2, 'post_type' => 'designapprovalsystem', 'orderby' => 'post_date', 'order' => 'DESC' ); $projects = get_posts( $project_args ); // get the project_id of the prior post //get the custom field value of a post $last_id = get_post_meta( $projects[1]->ID, 'job_number', true ); // increment $last_id++; // set the project_id of the current post update_post_meta( $post_id, 'job_number', $last_id );
} } add_action( 'save_post', 'auto_assign_ids', 100, 3 );