Skip to content

Instantly share code, notes, and snippets.

@gregogalante
Last active February 12, 2016 13:15
Show Gist options
  • Save gregogalante/4a5550685b2662231e7b to your computer and use it in GitHub Desktop.
Save gregogalante/4a5550685b2662231e7b to your computer and use it in GitHub Desktop.
Permette di copiare titolo e contenuto di un post da una lingua all'altra attraverso i comandi di duplicazione di Polylang. Codice da inserire nel function.php
<?php
// Make sure Polylang copies the content when creating a translation
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' );
// Make sure Polylang copies the title when creating a translation
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' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment