Filter heading widgets and change their content in Elementor

// Custom function to filter heading widget content
function custom_change_heading_content( $content, $widget ) {
    if ( 'heading' === $widget->get_name() && 'my-unique-css-id' === $widget->get_settings( 'css_id' ) ) {
        $content = 'New heading content goes here';
    return $content;
add_filter( 'elementor_pro/widget/render_content', 'custom_change_heading_content', 10, 2 );

This code uses the “elementor_pro/widget/render_content” filter to target the heading widget with the CSS ID “my-unique-css-id” and replace its content with “New heading content goes here”. Make sure to replace “my-unique-css-id” with the actual CSS ID you have assigned to the heading widget.

Also, you should note that in the above example, it uses Elementor Pro widgets , if you are using Elementor free version use “elementor/widget/render_content” instead of “elementor_pro/widget/render_content”

You can add this code to your theme’s functions.php file or in a plugin.