Support » Plugin: MultilingualPress » How to translate Custom Fields

Viewing 1 replies (of 1 total)
  • Plugin Author Fuxia

    (@thefuxia)

    The problem is not so much how to register custom fields, but how to show them. Each plugin needs something special here. Multilingual Press cannot get that right for everyone, so we don’t even try.

    But we do something better: we offer hooks. Look in inc/core/views/Mlp_Translation_Metabox_View.php at the method render(). It is just a list of specialized hooks for every place and oppurtunity. To add your field here, use one of these hooks.

    Example

    add_action(
    	'mlp_translation_meta_box_main',
    	function( $original_post, $remote_blog_id, $remote_post ) {
    
    		// print custom field here
    }, 10, 3 );

    Multilingual Press will now update the translation with that field. I recommend to to include the remote post id into the name attribute to get the proper context during the save action.

    You can also control how the data is saved and when. Look in inc/core/models/Mlp_Translatable_Post_Data.php at the method save() and the various filters.

Viewing 1 replies (of 1 total)
  • The topic ‘How to translate Custom Fields’ is closed to new replies.