Fixing Elementor’s Star Rating Schema Issue

Summarize with AI

At Hueston, we’re always digging into the details that help businesses run smoother online. Recently, we noticed a persistent issue in Elementor’s Star Rating/Rating widget: schema markup (microdata) was being injected into the page—even when it wasn’t wanted.

If you rely on an SEO plugin (Yoast, Rank Math, SEOPress, etc.) to manage structured data, this extra schema can create duplicates or conflicts. Worse, Elementor didn’t provide the same “disable schema” toggle in these widgets that it offers elsewhere.

So, we built one.

The Problem

Elementor’s Star Rating and Rating widgets automatically output microdata like itemscope, itemtype, and itemprop. For many sites, this isn’t ideal:

  • You already have schema handled elsewhere.

  • You don’t want ratings showing in Google Rich Results on certain pages.

  • You want consistent, reliable control over structured data output.

But in Elementor, there was no way to disable it at the widget level.

Our Solution

Elementor Star Rating Schema

We created a code snippet that does two things:

  1. Adds a new “Use Schema” toggle to both the legacy Star Rating and current Rating widgets.

  2. Strips microdata when the toggle is switched off—keeping your markup clean and conflict-free.

The Code

Add this snippet to your theme’s functions.php file (or better, a child theme or small mu-plugin for update safety):

// === Elementor: add "Use Schema" toggle to Star Rating / Rating widgets ===
if ( defined( 'ELEMENTOR_VERSION' ) ) {

    // Helper to register the control on a given widget + section
    $__register_rating_toggle = function( $widget_slug, $section_id ) {
        add_action( "elementor/element/{$widget_slug}/{$section_id}/before_section_end", function( $element, $args ) {
            if ( method_exists( $element, 'add_control' ) && class_exists( '\Elementor\Controls_Manager' ) ) {
                if ( ! $element->get_controls( 'use_schema' ) ) {
                    $element->add_control(
                        'use_schema',
                        [
                            'type'         => \Elementor\Controls_Manager::SWITCHER,
                            'label'        => __( 'Use Schema', 'elementor' ),
                            'label_on'     => __( 'Enable', 'elementor' ),
                            'label_off'    => __( 'Disable', 'elementor' ),
                            'return_value' => 'yes',
                            'default'      => 'yes',
                        ]
                    );
                }
            }
        }, 10, 2 );
    };

    foreach ( [ 'star-rating', 'rating' ] as $slug ) {
        foreach ( [ 'section_rating', 'section_rating_style' ] as $section ) {
            $__register_rating_toggle( $slug, $section );
        }
    }

    // Strip schema when toggle is OFF
    add_filter( 'elementor/widget/render_content', function( $content, $widget ) {
        if ( is_admin() || ! is_string( $content ) || $content === '' ) {
            return $content;
        }
        if ( ! method_exists( $widget, 'get_name' ) ) {
            return $content;
        }
        $widget_name = $widget->get_name();
        if ( $widget_name !== 'star-rating' && $widget_name !== 'rating' ) {
            return $content;
        }

        $settings   = $widget->get_settings_for_display();
        $use_schema = isset( $settings['use_schema'] ) ? (bool) $settings['use_schema'] : true;
        if ( $use_schema ) {
            return $content;
        }

        // Remove microdata attributes + meta tags
        $content = preg_replace( '#\sitemscope(?:=\s*(["\']).*?\1)?#i', '', $content );
        $content = preg_replace( '#\sitemtype=("|\').*?\1#i', '', $content );
        $content = preg_replace( '#\sitemprop=("|\').*?\1#i', '', $content );
        $content = preg_replace( '#<meta[^>]+itemprop=("|\').*?\1[^>]*>\s*#i', '', $content );

        return $content;
    }, 10, 2 );
}

 

How to Use It

  1. Add the code to your site (child theme or mu-plugin recommended).

  2. Open Elementor and edit a page with a Rating or Star Rating widget.

  3. You’ll now see a Use Schema toggle in the widget settings.

  4. Flip it off when you don’t want schema.

Testing

  • Run the page through Google’s Rich Results Test.

  • Confirm that disabling schema removes AggregateRating or Rating data from the widget.

  • Make sure your SEO plugin’s schema is still working as expected.

Why This Matters

Structured data is too important to leave messy. With this toggle, you can decide—per widget—whether to output schema or not. That means:

  • No more duplicate or conflicting markup.

  • Cleaner results in Google.

  • Simpler, more consistent SEO management.

Final Word

This is a small but powerful fix for anyone running Elementor. It gives you control where Elementor didn’t and keeps your structured data strategy tidy.

At Hueston, we’re here to solve problems like this—quietly, effectively, and with the details handled.

Win on the web with Hueston.

Share
Win on
the web with
Hueston.

Take your business to the next level with a partner who’s as committed to your growth as you are.

Is Your Business Invisible in AI Search Results?

Join our free webinar to learn how you can show up ahead of your competitors, and dominate AI/LLM searches.

Limited Spots