• 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 290

    I’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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Chouby

    (@chouby)

    Hello,

    You are using Polylang Pro and it is not allowed to support Premium plugins on this forum. Please contact the Polylang Pro helpdesk at https://polylang.pro/support/

    Thread Starter slotstartslotend

    (@slotstartslotend)

    Hi @chouby, I didn’t mean to go against the rules, however, I have contacted support and I was told I couldn’t be helped further and had to seek help somewhere else. This is me trying to get help somewhere else.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Automatic sync for posts’ is closed to new replies.