Assign category from custom field on post creation and update
After getting year, you may check if category exists using category_exists($cat_name); if not found then create category using wp_create_category( $cat_name, $parent ); after that you may create post using $my_post = array( ‘post_title’ => wp_strip_all_tags( $_POST[‘post_title’] ), ‘post_content’ => $_POST[‘post_content’], ‘post_status’ => ‘publish’, ‘post_author’ => 1, ‘post_category’ => array( 8,39 ) ); // Insert the … Read more