Home / functions.php / Remove role=”search” in get_search_form()
  • How to Remove role=”search” in get_search_form()


    Adding this PHP snippet to the functions.php of your wordpress theme will remove the role=”search” from the get_search_form() HTML output. Please note that role is an attribute introduced in XHTML draft for accessibility however does not validate.

    ( click code to copy )

    wordpress snippet : PHP

    function valid_search_form ($form) {
        return str_replace('role="search" ', '', $form);
    add_filter('get_search_form', 'valid_search_form');

    ( WordPress codex functions, hooks, in this snippet. )

    add_filter, get_search_form,