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'); |
$cpt is an array, if you only need to exclude 1 CPT then remove 'b' => 'WP Deals Engine' and change Woocommerce to your CPT.
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
Hi,
Sorry but I have only got to trying this now.
Reason being is I have a new Amazon Products plugin that uses WooCommerce for display etc and once the auto-products get created, the author description is getting displayed.
I don't know why but this snippet doesn't work.
I presume instead of Woocommerce above that I'm using the proper CPT of product, yes?
Any other thoughts on why it doesn't work?