Created
September 3, 2013 17:41
-
-
Save SanjeevMohindra/6427084 to your computer and use it in GitHub Desktop.
Remove Author Box For Selected CPT
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
function remove_author_box( $post_id ) { | |
// - Update the array for selected CPT, where you do not want to display the author box | |
$CPT = array('a'=>'Woocommerce', 'b'=>'WP Deals Engine'); | |
// If this isn't a selected CPT post, don't update it. | |
if ( in_array ($_POST['post_type'], $CPT )) { | |
// - Update the post's metadata. | |
update_post_meta( $post_id, 'author_disp', 'NO'); | |
} | |
} | |
add_action( 'save_post', 'remove_author_box'); |
Thanks for replying but the code simply does not work.
Any other ideas?
I am using:
function remove_author_box( $post_id ) {
// - Update the array for selected CPT, where you do not want to display the author box
$CPT = array('a'=>'product');
// If this isn't a selected CPT post, don't update it.
if ( in_array ($_POST['post_type'], $CPT )) {
// - Update the post's metadata.
update_post_meta( $post_id, 'author_disp', 'No');
}
}
add_action( 'save_post', 'remove_author_box');
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$cpt is an array, if you only need to exclude 1 CPT then remove 'b' => 'WP Deals Engine' and change Woocommerce to your CPT.