Created
August 22, 2014 03:06
-
-
Save Kenshino/9cf053d4845e7696ff59 to your computer and use it in GitHub Desktop.
Unset product post type from categories
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
function unset_preorder_terms( $product ) { | |
if ( is_object( $product ) ) | |
$product = $product->id; | |
$terms = wp_get_post_terms($product, 'product_cat'); | |
$term_ids = array(); | |
foreach ( $terms as $term ){ | |
if ( strpos($term->slug, 'pre-order') === false ){ | |
$term_ids[] = $term->term_id; | |
} | |
} | |
wp_set_post_terms( $product, $term_ids, 'product_cat'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment