Skip to content

Instantly share code, notes, and snippets.

@sproutventure
Created August 21, 2010 17:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sproutventure/542588 to your computer and use it in GitHub Desktop.
Save sproutventure/542588 to your computer and use it in GitHub Desktop.
/**
* Creates a nexus term on publish
*
* @param string $id
* @param string $post
* @return void
* @author Dan Cameron
*/
function autoadd_nexus_category($id, $post) {
if( $post->post_status == 'publish' && false === (wp_is_post_autosave($post) || wp_is_post_revision($post) )
&& !in_array( $post->post_type, array('page')) // array of post types that we do not want to auto-create terms
) {
wp_set_object_terms($id, array($post->post_title), 'nexus', 1);
}
}
add_action('save_post', 'autoadd_nexus_category', 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment