Validate the WordPress Sidebar Widget

As standard the wordpress sidebar widget does NOT validate as HTML – this is because WordPress gives it a role for Accessibilty!

However if you have a client that demands HTML Validity – or you just prefer it then you can very simply edit the Core WordPress Files – However this will be changed on a wordpress update.

So we make our functions.php to re-write the role="search" out of the.

So what we do is we include a function to your themes functions.php

// Makes the WordPress Sidebar Search HTML Valid
function valid_search_form ($form) {
return str_replace('role="search" ', '', $form);
add_filter('get_search_form', 'valid_search_form');

That’s it!

, ,

Leave a Reply

Your email address will not be published.