Skip to content

Instantly share code, notes, and snippets.

@SanjeevMohindra
Created September 3, 2013 17:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SanjeevMohindra/6427084 to your computer and use it in GitHub Desktop.
Save SanjeevMohindra/6427084 to your computer and use it in GitHub Desktop.
Remove Author Box For Selected CPT
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');
@rastarr
Copy link

rastarr commented Feb 4, 2014

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?

@SanjeevMohindra
Copy link
Author

$cpt is an array, if you only need to exclude 1 CPT then remove 'b' => 'WP Deals Engine' and change Woocommerce to your CPT.

@rastarr
Copy link

rastarr commented Aug 31, 2014

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