Support Forum ยป User Profile

Forum Replies Created

Viewing 9 posts - 16 through 24 (of 24 total)
  • Author
    Posts
  • in reply to: โœ…MB Block Not Saving Data #23675
    Jacob HillJacob Hill
    Participant

    The reason I want to save the data into post meta is so I can access the field data using Beaver Builder, but still have the modern editing experience that Gutenberg provides on the back end.

    in reply to: โœ…MB Block Not Saving Data #23674
    Jacob HillJacob Hill
    Participant

    Hello! Thank you for the quick response! Regarding question 2, I'd love to get help with custom code to get this done since MB doesn't support it out of the box. But the 1st priority is solving question 1, as the data isn't saving. ๐Ÿ™‚

    Sure! Here is the CPT code:

    // Creates the CPT.
    add_action( 'init', 'tekfused_register_cpt_requests' );
    function tekfused_register_cpt_requests()
    {
        $args = array (
            'label' => esc_html__( 'Requests', 'tekfused-cpt-requests' ),
            'labels' => array(
                'menu_name' => esc_html__( 'Requests', 'tekfused-cpt-requests' ),
                'name_admin_bar' => esc_html__( 'Request', 'tekfused-cpt-requests' ),
                'add_new' => esc_html__( 'Add new', 'tekfused-cpt-requests' ),
                'add_new_item' => esc_html__( 'Add new Request', 'tekfused-cpt-requests' ),
                'new_item' => esc_html__( 'New Request', 'tekfused-cpt-requests' ),
                'edit_item' => esc_html__( 'Edit Request', 'tekfused-cpt-requests' ),
                'view_item' => esc_html__( 'View Request', 'tekfused-cpt-requests' ),
                'update_item' => esc_html__( 'Update Request', 'tekfused-cpt-requests' ),
                'all_items' => esc_html__( 'All Requests', 'tekfused-cpt-requests' ),
                'search_items' => esc_html__( 'Search Requests', 'tekfused-cpt-requests' ),
                'parent_item_colon' => esc_html__( 'Parent Request', 'tekfused-cpt-requests' ),
                'not_found' => esc_html__( 'No Requests found', 'tekfused-cpt-requests' ),
                'not_found_in_trash' => esc_html__( 'No Requests found in Trash', 'tekfused-cpt-requests' ),
                'name' => esc_html__( 'Requests', 'tekfused-cpt-requests' ),
                'singular_name' => esc_html__( 'Request', 'tekfused-cpt-requests' ),
            ),
            'public' => true,
            'exclude_from_search' => true,
            'publicly_queryable' => false,
            'show_ui' => true,
            'show_in_nav_menus' => true,
            'show_in_admin_bar' => true,
            'show_in_rest' => true,
            'menu_icon' => 'dashicons-list-view',
            'hierarchical' => false,
            'has_archive' => false,
            'template' => array(
                 array( 'meta-box/request' ),
            ),
            'template_lock' => 'all',
            'query_var' => false,
            'can_export' => true,
            'supports' => array(
                'title',
                'editor',
            ),
            'rewrite' => array(
                'slug' => 'requests',
            ),
            'capability_type' => array( 'request', 'requests' ),
            'map_meta_cap' => true,
        );
    
        register_post_type( 'tf-requests', $args );
    }

    And here is the MB block code:

    // Creates the fields.
    add_filter( 'rwmb_meta_boxes', 'tekfused_register_meta_box_requests_info' );
    function tekfused_register_meta_box_requests_info( $meta_boxes )
    {
        $prefix = '_tf_requests_';
    
        $meta_boxes[] = array (
            'title' => esc_html__( 'Request Info', 'tf-meta-box-request-info' ),
            'id' => 'request',
            'post_types' => array(
                0 => 'tf-requests',
            ),
            'context' => 'normal',
            'priority' => 'high',
            'revision' => true,
            'type' => 'block',
            'mode' => 'edit',
            'category' => 'common',
            'icon' => 'awards',
            'supports' => [
                 'multiple' => false,
            ],
            'keywords' => ['image', 'photo', 'pics'],
            'fields' => array(
                array (
                    'id' => $prefix . 'category',
                    'name' => esc_html__( 'Category', 'tf-meta-box-request-info' ),
                    'type' => 'select',
                    'required' => 1,
                    // 'placeholder' => esc_html__( 'Select a Category', 'tf-meta-box-request-info' ),
                    'tooltip' => esc_html__( 'The category of request.', 'tf-meta-box-request-info' ),
                    'options' => array(
                        // Blank option.
                        '' => esc_html__( '', 'tf-meta-box-request-info' ),
                        'Other' => esc_html__( 'Other', 'tf-meta-box-request-info' ),
                    ),
                ),
                array (
                    'id' => $prefix . 'description',
                    'type' => 'textarea',
                    'name' => esc_html__( 'Description', 'tf-meta-box-request-info' ),
                    'tooltip' => esc_html__( 'A description of the request.', 'tf-meta-box-request-info' ),
                ),
            ),
            'text_domain' => 'tf-meta-box-request-info',
            // Attempt to get this to save to Post Meta --- this is related to question 2, first issue to solve is why the data is not saving.
            /*
            'attributes' => array(
                $prefix . 'category' => array(
                    'type' => 'string',
                    'source' => 'meta',
                    'meta' => $prefix . 'category'
                ),
                $prefix . 'description' => array(
                    'type' => 'string',
                    'source' => 'meta',
                    'meta' => $prefix . 'description'
                ),
            ),
            */
        );
    
        return $meta_boxes;
    }

    Please let me know if you if you have any other questions - and thanks again for the fast response!

    Jacob Hill

    Jacob HillJacob Hill
    Participant

    Excellent! Can this be added to the blocks extension's documentation? https://docs.metabox.io/extensions/mb-blocks/

    Jacob HillJacob Hill
    Participant

    Can this be added to the blocks extension's documentation? https://docs.metabox.io/extensions/mb-blocks/

    Jacob HillJacob Hill
    Participant

    I figured this out! I had to use different syntax:

    'template' => array(
        array( 'meta-box/{$block_id}' ),
    ),
    'template_lock' => 'all',
    Jacob HillJacob Hill
    Participant

    I'm wondering the same thing! I'd like to create a CPT, register a block, and then REQUIRE that block on new CPT items, but prevent other blocks from being added.

    When I add the template line, I also get a blank page.

    Reference: https://wordpress.org/support/topic/is-it-possible-to-create-a-standardized-and-fixed-blocks-cpt/#post-12773298

    in reply to: Add Comments Metabox to wp-admin Edit Entry Interface #18292
    Jacob HillJacob Hill
    Participant

    Hello, any info?

    in reply to: Admin Columns Not Showing Data #18178
    Jacob HillJacob Hill
    Participant

    Thank you for testing! I believe there may be a conflict somewhere, I'll work on identifying that tonight.

    in reply to: Admin Columns Not Showing Data #18128
    Jacob HillJacob Hill
    Participant

    Any update? Let me know if you need any more info.

Viewing 9 posts - 16 through 24 (of 24 total)