Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Manage Taxonomies
- function tax_hadle_func($post_id, $post) {
- $terms = wp_get_post_terms($post_id, 'product_cat', array("fields" => "all"));
- $boat_ids = toolset_get_related_posts($post_id, 'boat-product', 'child');
- $ids = array_map(function ($term) {
- return get_term_by('slug', $term->slug, 'boat-cat')->term_id;
- }, $terms);
- // print_r( $ids );
- remove_action('save_post', 'tax_hadle_func',30,2);
- add_action('save_post', 'tax_hadle_func',30,2);
- foreach ($boat_ids as $boat_id) {
- wp_set_object_terms($boat_id, $ids, 'boat-cat', true );
- }
- }
- add_action('save_post', 'tax_hadle_func',30,2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement