Created
March 22, 2021 23:11
-
-
Save pixelbart/f24440e8ef53c288ac9670d6a1e2d133 to your computer and use it in GitHub Desktop.
Disable Helpful in a specific term of a taxonomy
This file contains 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 | |
/** | |
* Disable helpful on new posts with specific term of taxonomy. | |
* | |
* @param int $post_id | |
* @param WP_Post $post | |
* @param bool $update | |
* | |
* @return void | |
*/ | |
function hide_helpful_on_new_posts( $post_id, $post, $update ) { | |
if ( $update || wp_is_post_revision( $post_id ) ) { | |
return; | |
} | |
/* to change: term from taxonomy */ | |
if ( ! has_term( 'term', 'taxonomy', $post_id ) ) { | |
return; | |
} | |
update_post_meta( $post_id, 'helpful_hide_on_post', 'on' ); | |
} | |
/* init hide_helpful_on_new_posts on post save */ | |
add_action( 'save_post', 'hide_helpful_on_new_posts', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Related links