Custom Fields
Support Meta Box Include Exclude Some fields won't save when using Include/Exclude

  • Creator
  • #28210
    Resolved Stephen C.

    I'm using Include/Exclude to include meta boxes on a frontend form, while making sure they don't show up on the form in the admin area (which already has the fields provided by a plugin). The meta boxes display properly based on the include parameters, but a few field types won't save unless I remove the Include/Exclude code.

    Image select/upload, date and datetime all fail to save when using Include/Exclude code, even though they display properly.

    The only Include/Exclude code I am using on the meta boxes is:

    'include' => array(
         'template' => array( 'template-single-form.php' )

    If I remove the Include/Exclude code, the fields save fine, but then I end up with those meta boxes showing up on the admin form, which I can't have since those fields already exist on the admin form.

    Any ideas of how to get this to work? Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
  • #28217
    Long Nguyen

    Hi Stephen,

    This is not the way of the extension MB Include Exclude works. If you set a meta box shows when the page/post has the template abc123.php, it will show in the backend (admin area) if you select the template here

    If you want to show a meta box and custom fields on the frontend form only, you can check if the admin area does not load.

    function my_custom_meta_boxes( $meta_boxes ){
        if( !is_admin() ) {
            $meta_boxes[] = array (
        return $meta_boxes;
    Stephen C.

    Just an FYI: Using !is_admin() causes those fields not to be saved when submitting the form via ajax.


    if( wp_doing_ajax() || !is_admin() ) {

    seems to work, though.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.