Support

Account

Home Forums General Issues Discrepancy between live page and page preview (using WPML)

Helping

Discrepancy between live page and page preview (using WPML)

  • I’m using WPML to add language translations to a site. I also have an options page (with sub pages) as set up by ACF Pro, to control content in the footer and header. The English version of the options page is filled in, but none of the other languages are.

    Here’s the odd thing – when I view the live version of the French home page, for example, I don’t see any links in the footer. But when I view the preview version of the same French page, I see all the links!

    To summerise:

    • All the custom fields on the French options sub-page are blank
    • When you view a French page, no custom fields from the sub page are visible
    • If you view the preview version of the French page, all the custom fields are now visible

    What’s happening here?

  • Hi @plinth

    Please keep in mind that ACF lets you translate the options page so you can have different setups for each language. If you want to have the same value on all of your languages, you can use the acf/save_post hook to update the options in the other languages. It should be something like this:

    function my_acf_save_options( $post_id ) {
        
        if( $post_id == 'options' ){
            $value = get_field('field_name', $post_id);
            update_field('field_name', $value, 'options_fr');
        }
        
    }
    
    // run after ACF saves the $_POST['acf'] data
    add_action('acf/save_post', 'my_acf_save_options', 20);

    With that code, you can update the options on the main language options page and it should be copied to the other languages (in this case, France).

    I hope this helps 🙂

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

The topic ‘Discrepancy between live page and page preview (using WPML)’ is closed to new replies.