Insert Post Hook
unknown
php
4 years ago
641 B
7
Indexable
function my_update_post_categories( $post_id ) { if ( wp_is_post_revision( $post_id ) ) return; $Categories = wp_get_post_categories( $post_id ); foreach($Categories as $c) { $cat = get_category($c); $CategoryNames[] = $cat->name; } // SBC Travel Category Merge $TravelCategories = array("Travel","Travel News","Travel/Tourism"); if (count(array_intersect($TravelCategories, $CategoryNames)) === 0) { // No values from array1 are in array 2 } else { $newcat = get_term_by( 'name', 'myTravelNews', 'category' ); wp_set_post_categories( $post_id, $newcat->term_id, true); } }
Editor is loading...