Last active
August 29, 2015 14:24
-
-
Save danielpowney/9fdc8761aef0bdd5bba5 to your computer and use it in GitHub Desktop.
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 | |
/** | |
* Sets post_tag taxonomy terms that are allowed to do auto placement | |
* | |
* @param boolean $can_apply_filter | |
* @param string $filter_name | |
* @param string $value | |
* @param int $post_id | |
* @return $can_apply_filter | |
*/ | |
function mrp_check_post_tag_auto_placement( $can_apply_filter, $filter_name, $value, $post_id ) { | |
if ( $can_apply_filter ) { | |
$found = false; | |
$terms = get_the_terms( $post_id, 'post_tag' ); // << add your taxonomy here in here | |
if ( $terms && is_array( $terms ) ) { | |
foreach ( $terms as $term ) { | |
// add your term names below in the array | |
if ( in_array( $term->name, array( 'term1', 'term2' ) ) ) { | |
$found = true; | |
break; | |
} | |
} | |
} | |
if ( ! $found ) { | |
$can_apply_filter = false; | |
} | |
} | |
return $can_apply_filter; | |
} | |
add_filter( 'mrp_can_apply_filter', 'mrp_check_post_tag_auto_placement', 10, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment