I have some wordpress custom fields (I'm not using ACF or any other plugin for this) and need to translate them using qTranslate X in wp-admin.
The fields that I created with wp_editor are working, but I don't know how to make it work with default <input type="text">
for other custom fields that I have.
Below, a piece of code that I'm using to set 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'm saving 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 knows how to make it work, without using ACF or any other plugin ? (My fallback solution is to create another custom fields just to save other language data, but solve it with qTranslate would be great)
thanks =D
Just use the inline syntax when adding the value on your input field e.g.
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<!--:-->
You can read more info from here https://qtranslatexteam.wordpress.com/faq/#CustomFields
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With