Support Forum » User Profile

Forum Replies Created

Viewing 15 posts - 2,101 through 2,115 (of 4,839 total)
  • Author
    Posts
  • Long NguyenLong Nguyen
    Moderator

    Hi,

    I do not see any issue with your code on my end. Screen record https://share.getcloudapp.com/7KuAE2Yy

    The code which I tested on the local site

    add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' );
    
    function your_prefix_function_name( $meta_boxes ) {
        $prefix = '';
    
        $meta_boxes[] = [
            'title'           => __( 'Featured Content', 'your-text-domain' ),
            'id'              => 'featured-content',
            'description'     => 'Displays featured content on the homepage.',
            'icon'            => 'star-filled',
            'category'        => 'theme',
            'keywords'        => ['featured'],
            'supports'        => [
                'align' => ['full'],
            ],
            'render_callback' => 'my_callback',
            'type'            => 'block',
            'context'         => 'side',
            'fields'          => [
                [
                    'name'     => __( 'Content Population', 'your-text-domain' ),
                    'id'       => $prefix . 'content_population',
                    'type'     => 'select',
                    'options'  => [
                        'auto'   => __( 'Auto-populate by category', 'your-text-domain' ),
                        'manual' => __( 'Manually populate', 'your-text-domain' ),
                    ],
                    'std'      => 'autopopulate',
                    'required' => true,
                ],
                [
                    'name'              => __( 'Fallback Category', 'your-text-domain' ),
                    'id'                => $prefix . 'fallback_category',
                    'type'              => 'taxonomy_advanced',
                    'label_description' => __( 'Select a fallback category for when there are not enough posts.', 'your-text-domain' ),
                    'taxonomy'          => ['category'],
                    'field_type'        => 'select_advanced',
                    'required'          => true,
                ],
                [
                    'name'    => __( 'Category Source', 'your-text-domain' ),
                    'id'      => $prefix . 'category_source',
                    'type'    => 'select',
                    'options' => [
                        'singlelocal'   => __( 'Single Local Category', 'your-text-domain' ),
                        'multiplelocal' => __( 'Multiple Local Categories', 'your-text-domain' ),
                        'syndicated'    => __( 'Syndicated Category', 'your-text-domain' ),
                    ],
                    'std'     => 'singlelocal',
                    'visible' => [
                        'when'     => [['content_population', '=', 'auto']],
                        'relation' => 'or',
                    ],
                ],
                [
                    'name'       => __( 'Autopopulated Single Category', 'your-text-domain' ),
                    'id'         => $prefix . 'autopopulated_single_category',
                    'type'       => 'taxonomy_advanced',
                    'taxonomy'   => ['category'],
                    'field_type' => 'select_advanced',
                    'visible'    => [
                        'when'     => [['category_source', '=', 'singlelocal']],
                        'relation' => 'or',
                    ],
                ],
                [
                    'name'       => __( 'Autopopulated Categories', 'your-text-domain' ),
                    'id'         => $prefix . 'autopopulated_categories',
                    'type'       => 'taxonomy_advanced',
                    'taxonomy'   => ['category'],
                    'field_type' => 'select_advanced',
                    'multiple'   => true,
                    'visible'    => [
                        'when'     => [['category_source', '=', 'multiplelocal']],
                        'relation' => 'or',
                    ],
                ],           
            ],
        ];
        return $meta_boxes;
    }
    
    function my_callback( $attributes, $is_preview = false, $post_id = null ) {
        // Fields data.
        if ( empty( $attributes['data'] ) ) {
            return;
        }
        mb_the_block_field( 'fallback_category' );
        echo '<br>';
        mb_the_block_field( 'autopopulated_single_category' );
    
    }
    in reply to: Gravity Form Advanced Post Creation and MB Custom Table #31746
    Long NguyenLong Nguyen
    Moderator

    Hi,

    A small problem is: the 1st time I run the script, it moved 1 record; the 2nd time => 2 records and so on... but what happen if I would have 100000 records?

    When you run the script, it will move all post meta of a post type from the table wp_postmeta to the custom table. Please read more here
    https://metabox.io/move-custom-fields-data-to-custom-tables/#step-2-move-the-data-to-the-new-custom-table

    So, is it possible to create custom post from GF post creation plugin (and other 3rd post creation plugin) that automatically store data In metabox custom table?

    I think it is not possible. GF form only supports storing custom field values in the standard table of WordPress wp_postmeta. You can contact GF form support to ask for help with this case.

    in reply to: frontend submission form for a cloneable field, only add! #31744
    Long NguyenLong Nguyen
    Moderator

    Hi Steffen,

    Do you mean to add new cloneable items and hide all previous cloneable items in the form? If yes, it is not possible. You might want to use the feature of MB Group that supports collapsing/expanding the group.
    https://docs.metabox.io/extensions/meta-box-group/#collapsible-groups

    in reply to: Targeting Singular Posts with MB Views #31738
    Long NguyenLong Nguyen
    Moderator

    Hi,

    I've also experienced that issue on my in a while. If you cannot select a specific post, that means the view is broken. Screenshot https://share.getcloudapp.com/nOu5P549

    You can try to create a new View and select the Location again. If you can select a specific post, the view will render the content as well. Screenshot https://share.getcloudapp.com/JrunDnRP

    in reply to: Controlling post status in front end dashboard #31734
    Long NguyenLong Nguyen
    Moderator

    Hi Kara,

    You should use the choice value in lower case.

    [
        'name'     => __( 'Save As', 'your-text-domain' ),
        'id'       => $prefix . 'save_as',
        'type'     => 'radio',
        'options'  => [
            'draft'   => __( 'Draft', 'your-text-domain' ),
            'publish' => __( 'Publish', 'your-text-domain' ),
        ],
        'std'      => 'draft',
        'required' => true,
        'inline'   => false,
    ],

    And the code to update the post status is

    add_action( 'rwmb_save_as_after_save_field', function( $null = true, $field, $new, $old, $object_id ) {
        $my_post = array(
            'ID' => $object_id,
            'post_status' => $new,
        );
    
        wp_update_post( $my_post );
    }, 10, 5 );
    in reply to: Targeting Singular Posts with MB Views #31733
    Long NguyenLong Nguyen
    Moderator

    Hi Matt,

    Please try to re-save the permalink (Post name) then check the Site Health status in Tools > Site Health if there is an error message with REST API. Some screenshots would be appreciated.

    in reply to: MB Views and Timber Conflict #31731
    Long NguyenLong Nguyen
    Moderator

    Hi,

    FYI, the MB Views plugin runs Twig functions/classes under the namespace MBViews. Please contact Timber plugin support to ask for help with this issue.

    in reply to: Custom image size #31718
    Long NguyenLong Nguyen
    Moderator

    Hi David,

    You can register a new image size name then pass the size name to the function as the second argument. Please read more on WordPress documentation
    https://developer.wordpress.org/reference/functions/get_the_post_thumbnail/
    https://developer.wordpress.org/reference/functions/add_image_size/

    {{ mb.get_the_post_thumbnail( post.ID, 'custom-size' ) }}
    
    in reply to: Add Post ID to Custom Field And Then to Admin Column #31717
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Just replace fieldID by your field ID pro_new_id

    add_action( 'rwmb_pro_new_id_after_save_field', function ( $null, $field, $new, $old, $post_id ) {
        $storage = $field['storage'];
        $storage->update( $post_id, $field['id'], $post_id );
    }, 10, 5 );
    Long NguyenLong Nguyen
    Moderator

    Hi,

    The parameter allow_delete supports displaying a button "Delete" on the frontend submit page. On the dashboard page, the user will have full control over the post Edit or Delete.

    Please read more here https://docs.metabox.io/extensions/mb-frontend-submission/#shortcode-attributes

    in reply to: Add Post ID to Custom Field And Then to Admin Column #31709
    Long NguyenLong Nguyen
    Moderator

    Hi Janos,

    You can create a text field, enable show in admin columns, then use the action hook rwmb_{$field_id}_after_save_field to update the field value by post ID. For example:

    add_action( 'rwmb_fieldID_after_save_field', function ( $null, $field, $new, $old, $post_id ) {
        $storage = $field['storage'];
        $storage->update( $post_id, $field['id'], $post_id );
    }, 10, 5 );

    Refer to this documentation https://docs.metabox.io/actions/#rwmb_after_save_field

    in reply to: Default block width #31703
    Long NguyenLong Nguyen
    Moderator

    Hi,

    It is called block alignment, but MB Blocks has not had an option to set the default alignment yet. I will inform the development team to support this in future updates.

    Long NguyenLong Nguyen
    Moderator

    Here you go https://share.getcloudapp.com/yAu06Kb4

    I've tested to create a new post (CPT), upload the PDF file, and publish the post. There is no issue like that. You can try to deactivate all plugins except Meta Box, switch to the standard theme of WordPress, and re-check this issue.

    in reply to: Post field: how to filter posts of certain categories? #31696
    Long NguyenLong Nguyen
    Moderator

    Hi,

    You can use the setting query_args to filter posts by taxonomy as well. Please read more on the documentation
    https://docs.metabox.io/fields/post/#settings
    https://developer.wordpress.org/reference/classes/wp_query/#taxonomy-parameters

    Long NguyenLong Nguyen
    Moderator

    Hi,

    I do not see any issue on my end, screen record https://share.getcloudapp.com/z8u1PYAO

    But after saving the post and reloading the page, you see the file icon still available in the field that means the value is saved to the database. Don't worry about the attached option of WordPress.

    You can also follow the documentation to output the field value to make sure it works https://docs.metabox.io/fields/file-advanced/#template-usage

Viewing 15 posts - 2,101 through 2,115 (of 4,839 total)