Created
January 20, 2017 18:26
-
-
Save solid-pixel/9eab37eeea4b50002d58437f97c7ee71 to your computer and use it in GitHub Desktop.
Assign Taxonomy Term with same name as Post Object's assigned 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
<?php | |
// Assign a taxonomy term with the same name as the Course assigned to the Tutor | |
function create_tutors_course($post_ID) { | |
global $wpdb; | |
$postObjectID = get_field('tutor_course', false, false); //grab the assigned Course's post ID | |
if($postObjectID) { | |
$catName = get_the_title($postObjectID); //grab the title of the Course | |
wp_set_object_terms($post_ID, $catName, 'course_name'); //course_name is the taxonomy slug | |
} | |
} | |
add_action('acf/save_post', 'create_tutors_course', 20); // This creates the term on Save | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment