Title: MaxMcNally's Replies | WordPress.org

---

# MaxMcNally

  [  ](https://wordpress.org/support/users/maxmcnally/)

 *   [Profile](https://wordpress.org/support/users/maxmcnally/)
 *   [Topics Started](https://wordpress.org/support/users/maxmcnally/topics/)
 *   [Replies Created](https://wordpress.org/support/users/maxmcnally/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/maxmcnally/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/maxmcnally/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/maxmcnally/engagements/)
 *   [Favorites](https://wordpress.org/support/users/maxmcnally/favorites/)

 Search replies:

## Forum Replies Created

Viewing 1 replies (of 1 total)

 *   Forum: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
   
   In reply to: [Custom Post Types adding info to Taxonomy](https://wordpress.org/support/topic/custom-post-types-adding-info-to-taxonomy/)
 *  Thread Starter [MaxMcNally](https://wordpress.org/support/users/maxmcnally/)
 * (@maxmcnally)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/custom-post-types-adding-info-to-taxonomy/#post-2180994)
 * I managed to get it to work by adding a filter instead of an action –
 *     ```
       add_filter('wp_insert_post_data','create_taxonomy_callback');
       ```
   
 * and here is my callback function –
 *     ```
       if($data['post_type'] == 'revision' || $data['post_status'] == 'auto-draft') {
       			//Ignore revisions
       			return $data;
       		}
   
       		if($data['post_type'] == 'villagelife' && !term_exists( $data['post_title'], 'villagelife' )){
       			wp_insert_term(
       			$data['post_title'], // the term
       				  'village' // the taxonomy
       			);
       		}
       ```
   
 * Hope that helps!

Viewing 1 replies (of 1 total)