I have an elementor page with a nav element.
The page returns a lot of errors on the w3c validator, like this one:
Error: Attribute migrated not allowed on element nav at this point.
<nav migration_allowed="1" migrated="0" role="navigation"
class="elementor-nav-menu--main elementor-nav-menu__container
elementor-nav-menu--layout-horizontal e--pointer-none">
I'm wondering how to remove these attributes, is it possible to edit the elementor pluign itself update-proof?
Or could I use a hook to edit it before rendering with PHP?
My Answer:
To remove the invalid attributes from the nav element in Elementor, you can use a filter hook in your theme's functions.php file. Here's an example code snippet that you can use:
php
add_filter( 'elementor/frontend/element/attributes', function( $attributes, $element ) {
if ( 'nav' === $element->get_name() ) {
unset( $attributes['migration_allowed'] );
unset( $attributes['migrated'] );
}
return $attributes;
}, 10, 2 );
This code snippet will remove the 'migration_allowed' and 'migrated' attributes from the nav element in Elementor before it is rendered on the frontend. This way, you can ensure that the invalid attributes are not included in the output.
Make sure to test this code on a staging site before implementing it on your live site to avoid any potential issues.
Rate this post
5 of 5 based on 1608 votesComments