This code creates a new meta box you can enable from the Screen Options on any Edit Post screen.
No need to install a plugin to create the meta box or check box.
The meta box includes a checkbox which you can tick or untick.
The value ( ticked or unticked ) is saved to the database using the $post_id
.
You can use the checkbox to enable or disable default or custom functionality in Genesis on every single post or page and even on custom post types.
In this example, the checkbox removes the author box from any single post.
The code creates a custom field included in the meta box checkbox form type.
Video Demo
Code Installation
All the code is included in a seperate file you simply upload to your child themes root directory and include the following line in your functions file:
include_once( get_stylesheet_directory() . '/author-box-checkbox.php' );
Here’s the file for members:
One last question Brad. When I use this in multisite, site administrators cannot see this meta box. In the original file I downloaded, the current_user_can (around line 18) is set to ‘unfiltered_html’ but only the super admins can see it in child pages. I’ve tried to set it to edit_pages, edit_post and edit_posts but site admins of child sites still cannot view it. Any suggestions? Thanks much.
Looks like a security risk however if you trust your site admins, try this https://kellenmace.com/add-unfiltered_html-capability-to-admins-or-editors-in-wordpress-multisite/
Thanks Brad. I’ll give it a go. Cheers!
Awesome Brad, works great.
One last thing I noticed was that while the Author Box Settings displays in the Screen Options when editing Posts, it does not display when editing Pages. I’m running the latest and greatest (WP 5.2.2, Genesis Core 3.0.2 and Genesis Sample 2.10.0).
Change
'post'
toarray('post','page')
Ok, that was too easy. Thanks again Brad.
Very helpful Brad. I’m using Genesis Sample theme on my local install and when I add this into the root of the child theme, the following message displays above the Title area in the dashboard when I’m editing a page or post…
constant post – assumed ‘post’ (this will throw an Error in a future version of PHP) in /app/public/wp-content/themes/genesis-sample/author-box-checkbox.php on line 21
Do you happen to have a fix you could offer?
Thanks again,
Mike
Hello Mike.
Thanks for letting me know about this error.
I have updated the download for you.
FYI, the 4th parameter for add_meta_box located on line 21 of author-box-checkbox.php was missing single quotes. Has now been changed from post to ‘post’
Cheers