Home Forums General Issues ACF widget dont save data.


ACF widget dont save data.

  • Hej. Sorry for my english. I have a problem with custom fields in widget. I create fields, but i haven’t save data. This problem view in this video And my test code:

    class CustomWidget extends WP_Widget {
    	function __construct() {
    			'custom_widget', // Base ID
    			__('CustomWidget', 'text_domain'), // Name
    			array( 'description' => __( 'Some CustomWidget', 'text_domain' ), ) 
    	public function form( $instance ){
    	public function widget( $args, $instance ) {
    		$title = apply_filters( 'widget_title', $instance['title'] );
    		// before and after widget arguments are defined by themes
    		echo $args['before_widget'];
    		if ( ! empty( $title ) )
    		echo $args['before_title'] . $title . $args['after_title'];
    		// This is where you run the code and display the output
    		<a href="test"><?php var_dump(get_field('dzialaj','widget_' . $args['widget_id']))?></a>
    		echo $args['after_widget'];
    // register Foo_Widget widget
    function register_foo_widget() {
        register_widget( 'CustomWidget' );
    add_action( 'widgets_init', 'register_foo_widget' );

    How fix it.

  • Hey @matib12 and @endcore.

    We’ve just released ACF 5.10 which includes a fix for this issue! Please let me know if you continue to have any problems after updating.

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


    1. Add Custom Widget
    2. Fill out loaded ACFs
    3. ID is<input class="widget-id" type="hidden" name="widget-id" value="media_widget-12"><– maybe the ID should be 1 not 12
    4. Click on Update
    5. Reload the page
    6. After reloading the Gutenberg the id has changed to media_widget-1:<input class="widget-id" type="hidden" name="widget-id" value="media_widget-1">

    Hope this will help.

  • + 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)

    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

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

You must be logged in to reply to this topic.