/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function save_taxonomy_data($post_id) { // verify this came from our screen and with proper authorization. if ( !wp_verify_nonce( $_POST['taxonomy_noncename'], 'taxonomy_theme' )) { return $post_id; } // verify if this is an auto save routine. If it is our form has not been submitted, so we dont want to do anything return $post_id; // Check permissions if ( 'page' == $_POST['post_type'] ) { if ( !current_user_can( 'edit_page', $post_id ) ) return $post_id; } else { if ( !current_user_can( 'edit_post', $post_id ) ) return $post_id; } // OK, we're authenticated: we need to find and save the data $post = get_post($post_id); if (($post->post_type == 'post') || ($post->post_type == 'page')) { // OR $post->post_type != 'revision' $theme = $_POST['post_theme']; wp_set_object_terms( $post_id, $theme, 'theme' ); } return $theme; }
URL: http://shibashake.com/wordpress-theme/wordpress-custom-taxonomy-input-panels