Custom Fields
Re-Envisioned
Support General WPML does not register custom fields for translation

Viewing 7 replies - 1 through 7 (of 7 total)
  • Author
    Replies
  • #29538
    VoB
    Participant
    <?php
    add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' );
    
    function your_prefix_function_name( $meta_boxes ) {
        $prefix = '';
    
        $meta_boxes[] = [
            'title'        => __( 'VoB Source for Article', 'your-text-domain' ),
            'id'           => 'vob-source-for-article',
            'post_types'   => ['vob-post-article'],
            'storage_type' => 'custom_table',
            'table'        => 'wp_custom_vob_source_for_article',
            'context'      => 'side',
            'priority'     => 'high',
            'fields'       => [
                [
                    'name'              => __( 'Source Name Tag', 'your-text-domain' ),
                    'id'                => $prefix . 'vob_article_source_name_tag',
                    'type'              => 'taxonomy_advanced',
                    'label_description' => __( 'Name of the publisher or web-site from taxonomy', 'your-text-domain' ),
                    'taxonomy'          => ['vob_source_name_tag'],
                    'field_type'        => 'select',
                    'placeholder'       => __( 'Select source name from the list', 'your-text-domain' ),
                    'add_new'           => true,
                ],
                [
                    'name'              => __( 'Source Name', 'your-text-domain' ),
                    'id'                => $prefix . 'vob_article_source_name',
                    'type'              => 'text',
                    'label_description' => __( 'Name of the publisher or web-site', 'your-text-domain' ),
                    'placeholder'       => __( 'Or add name of the publisher or web-site here', 'your-text-domain' ),
                ],
                [
                    'name'              => __( 'Source URL', 'your-text-domain' ),
                    'id'                => $prefix . 'vob_article_source_url',
                    'type'              => 'url',
                    'label_description' => __( 'Link to content source', 'your-text-domain' ),
                    'placeholder'       => __( 'Add source URL', 'your-text-domain' ),
                ],
                [
                    'name'              => __( 'Journalist / Author', 'your-text-domain' ),
                    'id'                => $prefix . 'vob_article_source_author',
                    'type'              => 'text',
                    'label_description' => __( 'Original article author name', 'your-text-domain' ),
                    'placeholder'       => __( 'Add article author', 'your-text-domain' ),
                ],
            ],
            'validation'   => [
                'rules' => [
                    $prefix . 'vob_article_source_url' => [
                        'required' => true,
                        'url'      => true,
                    ],
                ],
            ],
        ];
    
        return $meta_boxes;
    }
    #29540
    Long Nguyen
    Moderator

    Hi,

    WPML searches the meta key (field ID) in the default WordPress table wp_postmeta to translate. So it does not work with the custom table. You can refer to these topics to translate custom fields that stored in the custom table
    https://wpml.org/forums/topic/content-in-custom-tables/
    https://wpml.org/forums/topic/translating-custom-database-tables-nivo-slider-for-wordpress-v033/

    #29543
    VoB
    Participant

    I saw those answers, but (1) they are old and (2) I use taxonomy advanced custom field for which Meta box has a special way of saving in DB. I was hoping to get some directions from Meta Box on this issue as it is claimed as 100% compatible with WPML.

    Custom tables for custom fields is one of Meta Box feature and there is no warning about any incompatibility with WPML for this feature. Translating custom fields via WPML strings feature is very inconvenient.

    Thanks!

    #29551
    Long Nguyen
    Moderator

    Thanks for the feedback.

    I'm going to inform the developer team to consider adding it to the to-do list for the future development of the plugin.

    #29554
    VoB
    Participant

    Great, thank a lot for your support! Is there any expected time to get this issue addressed?

    #29753
    VoB
    Participant

    Hi Long! I wonder if you have any updates on this request. Thank you!

    #30139
    VoB
    Participant

    Hi! Is there any update on this issue? Thank you!

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