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

  • Creator
    Topic
  • #28210
    Resolved Stephen C.
    Participant

    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 1 replies (of 1 total)
  • Author
    Replies
  • #28217
    Long Nguyen
    Moderator

    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 https://share.getcloudapp.com/QwuEpooy

    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;
    }
    
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.