Add Genesis Meta Box for Checkbox

This code creates a new meta box you can enable from the Screen Options on any Edit Post screen.

screen-options

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.

meta-box-check-box

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:

Related Code


Comments

8 responses to “Add Genesis Meta Box for Checkbox”

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

      1. Thanks Brad. I’ll give it a go. Cheers!

  2. Mike Childress Avatar
    Mike Childress

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

    1. Change 'post' to array('post','page')

      1. Mike Childress Avatar
        Mike Childress

        Ok, that was too easy. Thanks again Brad.

  3. Mike Childress Avatar
    Mike Childress

    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

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

Leave a Reply

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.