Copy the Content from the Original Post When Using WordPress Polylang Plugin
If we have a website built with WordPress and we want to add multi-language support to it, one of the best free plugins we can use in WordPress is Polyang.
When using the free version of the Polylang plugin, we will see that the translation does not come with the original content when we want to translate blog posts or web pages. To solve this, we need to copy the following code blocks into the theme’s functions.php file.
// Copying content when creating a translation with Polylang function jb_editor_content( $content ) { // Polylang sets the 'from_post' parameter if ( isset( $_GET['from_post'] ) ) { $my_post = get_post( $_GET['from_post'] ); if ( $my_post ) return $my_post->post_content; } return $content; } add_filter( 'default_content', 'jb_editor_content' ); // Copying content when creating a translation with Polylang function jb_editor_title( $title ) { // Polylang sets the 'from_post' parameter if ( isset( $_GET['from_post'] ) ) { $my_post = get_post( $_GET['from_post'] ); if ( $my_post ) return $my_post->post_title; } return $title; } add_filter( 'default_title', 'jb_editor_title' );
3 thoughts on “Copy the Content from the Original Post When Using WordPress Polylang Plugin”
Leave a Reply
You must be logged in to post a comment.
Thank you … its good work
fantastic..I have been looking for a solution for days .. thanks a lot …
Awesome it worked thank you so much, you just same my day 🙂