- This topic has 13 replies, 4 voices, and was last updated 3 months, 1 week ago by
Fernando.
-
AuthorPosts
-
April 15, 2022 at 8:48 am #2189984
Holly
Hi. I used this code found here: https://generatepress.com/forums/topic/how-to-add-a-label-to-the-navigation-search-form/#post-1402625 to add a search label for accessibility. I added it in the theme function php file and it saved without error. But it did not add a label.
My site is https://fresheggs.biz/
What am I missing?Thanks!
April 15, 2022 at 8:54 am #2189992David
StaffCustomer SupportHi there,
are you using a Child Theme ?
If you’re not, can you remove the code and add it to your site using the Code Snippets plugin:https://wordpress.org/plugins/code-snippets/
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/April 15, 2022 at 2:24 pm #2190171Holly
I am using a child theme yes. But the code is not working.
April 15, 2022 at 6:50 pm #2190239Ying
StaffCustomer SupportHi Holly,
I just tested the code, it is working well.
So you’ve added this code to your child theme’s
functions.php
file?Can you try remove it and use the code snippet plugin to eliminate PHP error in your theme file?
And if you are using any cache plugins, try disable them.
April 16, 2022 at 12:57 pm #2190922Holly
Yes, the code is in the child theme’s functions.php file.
I am not getting a PHP error in my theme file. The code just isn’t working (adding the label).
I disabled the caching plugin but the code still isn’t working.April 16, 2022 at 5:59 pm #2191000Ying
StaffCustomer SupportThe code should work.
There might be some kind of conflicts with your other PHP code.
Can you switch to parent theme and using code snippet plugin to test?
April 18, 2022 at 12:09 pm #2192694Holly
I switched to the parent theme and used the code snippets plugin. It still isn’t working.
April 18, 2022 at 2:33 pm #2192772Ying
StaffCustomer SupportThe label has been added to your site:
https://www.screencast.com/t/eJjSefJEFeIt’s using the body text color which is hard to see.
April 19, 2022 at 7:43 am #2193464Holly
Ah! Thank you. How do I change the color? Shouldn’t it be seen when it’s not open – next to the magnifying glass?
April 19, 2022 at 7:46 am #2193470David
StaffCustomer SupportAdd this CSS to change the color of the label:
label[for*="nav-search"] { color: #fff; }
It appears above the Search Form. Do you also wat some text beside the Search Icon ?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/May 1, 2022 at 7:32 am #2205512Holly
Yes. Text beside the icon I have mainly been trying to accomplish for accessibility. Thanks.
May 1, 2022 at 5:42 pm #2205915Fernando Customer Support
Hi Holly,
To add a label to the Search Icon, you may try adding this CSS in Appearance > Customize > Additonal CSS:
.main-navigation .search-item a:before { content: 'Search: '; display: inline; }
On Desktop view though, the Search Icon wraps down because there isn’t enough space. You’ll need to reduct the menu item spacing or font size. Or, you can just apply it to tablet and mobile view with this code instead:
@media (max-width: 1024px) { /* CSS in here for tablet only */ .main-navigation .search-item a:before { content: 'Search: '; display: inline; } }
Kindly replace
1024
with your preferred breakpoint. I think yours is set to go on tablet view at1107px
.Hope this helps! 🙂
May 2, 2022 at 12:34 pm #2206923Holly
Thank you!
May 2, 2022 at 4:56 pm #2207085Fernando Customer Support
You’re welcome Holly! Glad to be of assistance! Feel free to reach out anytime you’ll need assistance with anything else. 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.