• I am using the following code to add my custom data attribute to the Elementor section. It’s working fine in the fronted, but the data attribute does not work when I edit the page using the Elementor.
    Is it possible to add the custom attributes when it’s in the edit mode?

    add_action( 'elementor/frontend/element/before_render', function ( \Elementor\Element_Base $element ) {
    	if ( ! $element->get_settings( 'my-custom-settings' ) ) {
    		return;
    	}
    
    	$element->add_render_attribute( '_wrapper', [
    		'class' => 'my-custom-class',
    		'data-my_data' => 'my-data-value',
    	] );
    } );

    Thanks

    The page I need help with: [log in to see the link]

  • The topic ‘How to add data attribute to the section for the editor?’ is closed to new replies.