0

How do you pass the aria_label parameter to get_search_form()?

I can't seem to pass the 'aria_label' parameter to get_search_form() in the correct way and can't find any examples. Lots with the first parameter 'echo' which works as in the documentation, but nothing I've tried for aria_label has made the search form add aria labels.

1

You can pass an array of attributes with aria_label attribute in it.
Try this:

get_search_form(array('aria_label' => 'search-form'));

This function gets a form from searchform.php by default and if you have this file in your theme and aria-label still missing, you need to check the code in this file. Sometimes developers do not include an option to set an aria-label.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.