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 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