WordPress.org

Forums

Multilingual Press
[resolved] How to translate Custom Fields (2 posts)

  1. Hugh H.
    Member
    Posted 1 year ago #

    Any news for this topic?

    I'm wondering if letting the user supply some info to the plugin could be a feasible approach. For example, select which fields are translatable, their type (text, select, wysiwyg, ...), ...

    https://wordpress.org/plugins/multilingual-press/

  2. toscho
    Member
    Plugin Author

    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Multilingual Press
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic