Translate content, not instance, per-post

The easiest approach would be to have custom fields on the edit page: one text field for every language you want to use (and perhaps different title fields?) For this you could use a plugin like ACF. This would provide an easy interface for non-tech editors.

Supposing you are building your own theme you can integrate the custom fields in your template. Always display the French text, test if fields for other languages are empty and if not include them as well. Then toggle with jQuery like you’re used to.

If you are using a third party theme, you would have to build a child theme with a filter in functions.php that adds the custom fields to a normal call to the_content (and the_title) and includes the css and jQuery for toggling the display. Like this:

$spanish_content="<div class="spanish">" . get_field('spanish_content') . '</div>';
apply_filters('the_content',$spanish_content);

(note: the get_field call is specific to the ACF plugin)

Leave a Comment