Automatic sync for posts
-
I’m working on a multilingual wordpress website using the Polylang plug-in on pages and custom post types.
What I’m looking for is a way to have every post synch automatically, without user input. When creating a new post type, a translation would be automatically created and all contents copied
After some research I figured the method above is used when duplicating/synchronizing posts in bulk:
$polylang = PLL(); $sync_model = new PLL_Sync_Post_Model( $polylang ); $sync_model->copy_post( $post_id, $lang, $sync ); $post_id is the source post id. $lang is the target language. $sync is false to simply duplicate the post, true to activate the synhronization.I tried to attach it to to the ‘save_post’ like this:
function polylang_sync($post_id) { $polylang = PLL(); $sync_model = new PLL_Sync_Post_Model( $polylang ); $sync_model->copy_post( $post_id, $lang, $sync ); } add_action( 'save_post', 'polylang_sync' );And I get the following error message:
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'polylang_sync' not found or invalid function name in (...)wp/wp-includes/class-wp-hook.php on line 290I’m not sure what I’m doing wrong, or what I could change about this to make it work. I tried variations of this to no avail, I may be taking the wrong approach here.
Thanks in advance
The topic ‘Automatic sync for posts’ is closed to new replies.