[Support request] How to add a label to the Navigation Search form

Home Forums Support How to add a label to the Navigation Search form

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1402205
    Gina

    Hi
    To comply with the Accessibility Guidelines that will become mandatory for public bodies in September, I need to add a label to the Navigation Search form that you can enable when customising the layout.
    There is no option to add a label when you enable the form.
    Could you advise me how to add one?
    Thanks
    Gina

    #1402625
    David
    Staff
    Customer Support

    Hi there,

    try adding this PHP Snippet to your site:

    add_filter( 'generate_navigation_search_output', function() {
        printf(  
            '<form method="get" class="search-form navigation-search" action="%1$s">
    	    <label for="nav-search">Search:</label>
                <input type="search" class="search-field" id="nav-search" value="%2$s" name="s" title="%3$s" />
                <input type="hidden" name="post_type" value="product" />
            </form>', 
            esc_url( home_url( '/' ) ), 
            esc_attr( get_search_query() ),   
            esc_attr_x( 'Search', 'label', 'generatepress' ) 
        ); 
    } );
    #1406235
    Gina

    Many thanks for your suggestion, this has successfully added a label tag.
    Thanks!

    #1406387
    David
    Staff
    Customer Support
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.