Fix WordPress search form (x)html validation errors

On September 14, 2010, in Web, by Bikas

A common problem with wordpress blogs or sites is that while validating the site we get validation error for the search form used in the site.

The error is for <form role=”search” method=”get” id=”searchform” action=”http://xadd..>..</form> where the validator does not validates role=”search”.

The step by step method to fix this issue is mentioned below:

  1. Login to your site through any ftp client where the wordpress site is installed.
  2. Search for the general-template.php file. It will be in the folder wp-includes.
  3. Open the file and search for the code $form = ‘<form role=”search” method=”get” id=”searchform” action=”‘ . home_url( ‘/’ ) . ‘” >
  4. Remove role=”search”, save the file and upload the file.

The search box will still work fine without any error. The positive thing is that you will not get any validation error due to your search form.