Elementor is widely regarded as one of the best page builders, offering powerful features and flexibility. However, sometimes you might encounter issues when optimizing for SEO and performance. One such issue is the automatic integration of URLs in the accordion widget titles, which can lead to crawlability problems detected during a PageSpeed Insights (PSI) test. In this post, we will guide you through a simple solution to disable URLs in Elementor accordion titles.
The Issue
When you test your Elementor page with PSI or other SEO tools, you may receive an error indicating crawlability issues due to the URLs embedded in accordion titles. This can negatively impact your SEO score and overall page performance. If you’re striving for a 100% SEO score, fixing this issue becomes essential.
The Solution
To resolve this problem, you can use a custom WordPress filter to replace the <a>
tags in accordion titles with <span>
tags. This ensures the titles are no longer treated as links, effectively disabling the URL integration.
Step-by-Step Guide
- Add the Custom Code Open your WordPress theme’s
functions.php
file or use a custom plugin to add the following code:add_filter( 'elementor/widget/render_content', function ( $widget_content, $widget ) { if ( 'toggle' === $widget->get_name() ) { $widget_content = preg_replace( '/<a[^>]*class="elementor-toggle-title"[^>]*>(.*?)<\/a>/', '<span class="elementor-toggle-title">$1</span>', $widget_content ); } return $widget_content; }, 10, 2 );
- Save the Changes After adding the code, save the file and refresh your website.
- Test Your Page Re-test your page using PSI or your preferred SEO tool. The crawlability issue should now be resolved, and your SEO score should improve.
Why This Works
The add_filter
function hooks into Elementor’s widget rendering process. It checks if the widget being rendered is the accordion (“toggle” in Elementor terms). If it is, the code uses preg_replace
to search for <a>
tags with the class elementor-toggle-title
and replaces them with <span>
tags, effectively removing the hyperlink functionality.
Conclusion
With this simple customization, you can disable the automatic URL integration in Elementor accordion titles, improving your website’s SEO and user experience. Elementor continues to be a top-tier page builder, and with a few tweaks like this, you can ensure your website remains fully optimized.
Do you have other Elementor customization challenges? Let us know in the comments, and we’ll be happy to help!