@vueloiv Take a look into the “name” keys of the configured fields.
WPML stores them into a configuration array like this:
[
// 'meta_key' => 'translation option'
'my_custom_field' => 2 //translate
]
If there are fields with the same “name” (meta_keys) the setting will be overwritten.
Field name in documentation
I recommend to use unique names
+ The ID in the frontend differs to the widget ID in backend:
class custom_Media_Widget extends WP_Widget
{
/**
* @param string $idBase
* @param string $name
* @param array $widgetOptions
* @param array $controlOptions
*/
public function __construct(
string $idBase = 'media_widget',
string $name = 'Media Asset Widget',
array $widgetOptions = [],
array $controlOptions = []
) {
$widgetOptions ['classname'] = 'media_widget';
$widgetOptions ['description'] = 'Widget for Media Assets';
parent::__construct($idBase, $name, $widgetOptions, $controlOptions);
}
public function widget($args, $instance)
{
var_dump($args['widget_id']);
//....
}
}
will output: string 'media_widget-3' (length=14)
Edit: The id/number which is set in the backend isn’t relevant anymore.
I test it on the meta widget and it show the same behaviour.
ID: meta-13 on save
ID: meta-2 in frontend
@lgladdy
I use locally
Wordpress 5.8.1
ACF version 5.10.2
Advanced Custom Fields Multilingual 1.9.1
WPML Media 2.6.5
WPML Multilingual CMS 4.4.12
WPML String Translation 3.1.10
WPML Translation Management 2.10.8.
When I save my custom widget, the widget get the ID media_widget-1
but the saved options receive the ID widget_media_widget-12
Workflow:
<input class="widget-id" type="hidden" name="widget-id" value="media_widget-12"><– maybe the ID should be 1 not 12Updatemedia_widget-1:<input class="widget-id" type="hidden" name="widget-id" value="media_widget-1">
Hope this will help.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.