Created
January 19, 2017 16:03
-
-
Save solid-pixel/d6828eae12b46fd4755131be67dc1868 to your computer and use it in GitHub Desktop.
Create taxonomy term with same name as Post Title
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create taxonomy term with same name as Post Title | |
function create_course_name($post_ID) { | |
global $wpdb; | |
$cat = get_the_title($post_ID); // grabs the post title | |
wp_set_object_terms($post_ID, $cat, 'course_name'); //course_name is the taxonomy slug | |
} | |
add_action('save_post', 'create_course_name'); // This creates the term on Save |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment