Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 9 replies, has 2 voices.

Last updated by Radu 4 years, 3 months ago.

Assisted by: Radu.

Author Posts
January 26, 2021 at 2:02 pm #7932225

Timo Baumgartner

Updating to the beta version of Advanced Custom Fields Multilingual did not fix my problem.

I created a new page for testing, added a few blocks, ... and all the fields which should not show up appeared inside the translation editor again :/

January 26, 2021 at 2:56 pm #7932951

Timo Baumgartner

Hi I'm back!

i installed the new beta version of wpml acf
i also installed acf, and my theme

i added a block (from my theme) to "Sample Page" and then created a translation job.
when translating the post i see following fields which should not be displayed (because of 'wpml_cf_preferences' => 0 in acf settings)

acf/cards/cards_0_content_cta_style
acf/cards/background_color
acf/cards/padding
acf/cards/width

the value of the translation is empty, when testing locally sometimes the value is copied ...

January 26, 2021 at 9:07 pm #7935783

Radu

Hey Timo,

Can you tell me how are the custom fields (cards_0_content_cta_style, background_color and so on) created, please? I'm asking this because they are not available here:
hidden link

I found the acf-fields.php file on the theme, but can you tell me how did you create this code, please?

Also, can you create a field group from scratch on the sandbox website and tell me if the settings are still not working, please? Maybe there's some other setting of the block that's causing this issue.

Thanks,
Radu

January 27, 2021 at 10:54 am #7939643

Timo Baumgartner

Hey Radu,

the acf-fields.php is generated using the ACF tools (generate PHP).

I created two new field groups, one displayed on posts, one attached to a block. They both act like expected at first (only the field set to translate appears inside the editor).

But when I exit the translation editor, edit the page, and then start translating again, the fields set to don't translate appear ...

Its also noteworthy that the same thing happened with the fields I use in my theme regularly. Only the field cta_style was there from the beginning (while it shouldnt), the others appeared just after re-entering the editor ...

January 28, 2021 at 2:56 pm #7952913

Radu

Hey Timo,

I tested this out a bit closer and it seems that no matter what value you set for wpml_cf_preferences, the custom field will always be available for translation.

I asked my colleagues if I should be doing anything else to make this work. They will have a look at this and come back to me (it shouldn't take long). I will keep you posted about the reply I'm getting on this.

Thanks,
Radu

January 28, 2021 at 4:46 pm #7954905

Radu

Hey Timo,

Can you create the XML configuration for these custom fields as well?

Here's what I did on my tests. I have this code for two custom fields:

if( function_exists('acf_add_local_field_group') ):

acf_add_local_field_group(array(
	'key' => 'group_5f855e9e50192',
	'title' => 'Courses',
	'fields' => array(
		array(
			'key' => 'field_5f855eae41a0a',
			'label' => 'Description',
			'name' => 'description',
			'type' => 'text',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => 0,
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'wpml_cf_preferences' => 0,
			'default_value' => '',
			'placeholder' => '',
			'prepend' => '',
			'append' => '',
			'maxlength' => '',
		),
		array(
			'key' => 'field_5f855ea441a09',
			'label' => 'Title',
			'name' => 'title',
			'type' => 'text',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => 0,
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'wpml_cf_preferences' => 0,
			'default_value' => '',
			'placeholder' => '',
			'prepend' => '',
			'append' => '',
			'maxlength' => '',
		),
	),
	'location' => array(
		array(
			array(
				'param' => 'post_type',
				'operator' => '==',
				'value' => 'post',
			),
		),
	),
	'menu_order' => 0,
	'position' => 'normal',
	'style' => 'default',
	'label_placement' => 'top',
	'instruction_placement' => 'label',
	'hide_on_screen' => '',
	'active' => true,
	'description' => '',
));
endif;

and this XML config added to WPML → Settings → Custom XML configuration tab:

<wpml-config>
    <custom-fields>
        <custom-field action="ignore">description</custom-field>
        <custom-field action="ignore">title</custom-field>
    </custom-fields>
</wpml-config>

Now, when I try to translate a post that contains these custom fields, they are not available for translation, just as you asked for.

Please give this a try for the custom fields that you're using and tell me how it works for you.

Thanks,
Radu

January 28, 2021 at 7:05 pm #7955725

Timo Baumgartner

Hey Radu, thanks for you reply!

Ok so this works, I don't even have to add any XML.

But it doesn't work for my fields, they are either there from the start (cta-style) or after modifying the post.

Adding them to the XML settings did nothing.

The cta-style field is from a field group used as clone in many different field groups.
The other fields (that re-appear) are appended to many different blocks. I noticed them being transformed: package-string-7-259, package-string-7-260, ... does this mean anything?

Thank you
Timo

February 1, 2021 at 9:27 am #7974723

Radu

Hey Timo,

Could you access this sandbox website:
hidden link

and configure WPML, the create the same custom field that you have on your website and have issues with, please? I just want to have a closer look at this and it's better to replicate this on a sandbox website instead of having a look at your website. This way, if we find a certain configuration that has issues, I will be able to escalate it to the 2nd tier support.

Thanks,
Radu

February 1, 2021 at 1:05 pm #7977245

Timo Baumgartner

Hi Radu,

thanks for your reply!

Why do I have to setup another sandbox ... everything is already set up in the previous sandbox ...

February 2, 2021 at 9:13 am #7984157

Radu

Hey Timo,

I checked the previous sandbox here:
hidden link

but I couldn't see the cta-style custom field. I could see some field groups:
hidden link

Can you tell me what should I be checking, please? I mean, did you add some PHP code anywhere or what should I be checking?
Can you add the PHP code to the function.php file of the Twenty Twenty theme, please?

Also, it would be great if you could create the actual field in Custom Fields area, so I can try to use the generated PHP code on my testing website and see what's going on.

Thanks,
Radu