Disable author meta box for specific pages and posts – WordPress

[gard]
Sometimes its necessary to give your posts or pages switches to turn on and off specific template elements on your site. WordPress makes it really easy:

 

If not already done, activate the Custom fields on the Screen Options menue at the upper right corner of your post:

Add New Post ‹ XSimulator — WordPress

Than create any field and value, e.g.:
Name: hide-author
Value: 0

You can call the name as you want it. We define it in the template next.

custom fields in WordPress

 

Now we open content.php and go to line 60:

<?php     if ( is_single() && get_the_author_meta( 'description' ) && is_multi_author() ) :?>
			<?php get_template_part( 'author-bio' ); ?>
		 <?php endif; ?>

Change it so something like:

if ( is_single() && get_post_meta($post->ID,  'hide-author', true) != '1') :
                    ?>
			<?php get_template_part( 'author-bio' ); ?>
		<?php endif; ?>

As you can see, you can grab  the new custom field and create a condition with:

 get_post_meta($post->ID,  'hide-author', true) != '1')

Now you can specify in all your posts and pages if you like to disable or enable the author box. Very easy!
[gard]

 

Written by

"Enthusiastic Sim-Racer from the north of germany. I write here about web development, hardware, software and latest motion simulator technologies."