How to make Wordpress text input text translatable with qTranslate X?

I have custom Wordpress fields (I don't use ACF or any other plugin for this) and you need to translate them using qTranslate X to wp-admin.

The fields that I created using wp_editor work, but I don’t know how to make it work with the default value <input type="text">for the other custom fields that I have.

Below is a piece of code that I use to set a variable and show my field:

    $services = isset( $values['services'] ) ? esc_attr( $values['services'][0] ) : '';
    wp_nonce_field( 'my_meta_box_nonce', 'meta_box_nonce' );
?>
<table>
    <tr>
        <td>
            <input type="text" name="services_title" value="<?php echo !empty($services_title) ? $services_title : ''; ?>" style="width: 100%" />
        </td>
    </tr>
</table>

then I save it with:

add_action( 'save_post', 'hotelSaveData' );
function hotelSaveData( $post_id )
{
    // Bail if we're doing an auto save
    if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;

    if (isset($_POST['services_title']))
        update_post_meta($post_id, 'services_title', wp_kses($_POST['services_title'], true));

}

Does anyone know how to make it work without using ACF or any other plugin? (My backup solution is to create other custom fields to save the data of another language, but solving it with qTranslate would be great)

thanks = D

+4
1

.

you can use this on input field value
[:en]Text Here for English Translation
[:de]Text Here for German Translation
[:es]Text Here for Spanish Translation[:] 

other inline syntax though I bet the input validator won't accept this tags
<!--:en-->English Text<!--:-->
<!--:de-->Deutsch<!--:-->

https://qtranslatexteam.wordpress.com/faq/#CustomFields

0

Source: https://habr.com/ru/post/1599143/


All Articles