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.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 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.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0