• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Search widget Validation Warning!

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Search widget Validation Warning!

This topic is: not resolved

Tagged: genesis search section, Search widget, validation

  • This topic has 1 reply, 2 voices, and was last updated 9 years, 11 months ago by Christoph.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • June 24, 2015 at 9:59 am #157403
    PhillipDewsBlogger
    Member

    I have been developing a child-theme on the genesis framework for a national blind charity and my brief included the criterion that the site passes website accesibility tests To WAI WCAG-AA and the W3C HTML5 Valaidation.

    I got most of it done now but I have added the search widget to the top right header widget! I did customise it slightly in my functions.php file with this code....

    add_filter( 'genesis_search_text', 'custom_search_text' );
    function custom_search_text($text) {
        return esc_attr( 'Search NFBUK' );
    }

    Bit I am still getting a validation warning on that serch wiget! more specifically the section area.... Heere is the warning....
    Warning: Section lacks heading. Consider using h2-h6 elements to add identifying headings to all sections.

    and here is the code the validation checker provides...
    get-area"><section↩id="search-3" class="widget widget_search"><div↩c

    I would still love to use this widget as it works really well on the site, but does any of you know how I can stop this warning by editing the code...
    Many thanks!
    - Phillip Dews

    July 2, 2015 at 10:39 pm #158253
    Christoph
    Member

    Hi Philip,

    this great plugin takes care of most of the accessibility issues of the current Genesis version:

    Genesis Accessible

    It includes a section just for the search widget:

    /** forms.php
    *	Description: Adds label and id to the search forms
    *	Author: Rian Rietveld
    *	Plugin URI: http://genesis-accessible.org/
    *	License: GPLv2 or later
    */
    
    //* Replace the search form, function adds a real label and an id for the search input field
    //* Based on the genesis_search_form with Genesis 2.0.2, keeps the filters
    
    add_filter( 'get_search_form', 'wpaccgen_get_search_form_uniqueid', 20 );
    
    /**
     * Replace the default search form with a Genesis-specific accessible form.
     *
     * The exact output depends on whether the child theme supports HTML5 or not.
     *
     * Applies the <code>genesis_search_text</code>, <code>genesis_search_button_text</code>, <code>genesis_search_form_label</code> and
     * <code>genesis_search_form</code> filters.
     *
     * @since 0.2.0
     *
     * @uses genesis_html5() Check for HTML5 support.
     *
     * @return string HTML markup.
     */
    function wpaccgen_get_search_form_uniqueid() {
    
    	$search_text = get_search_query() ? apply_filters( 'the_search_query', get_search_query() ) : apply_filters( 'genesis_search_text', __( 'Search this website', 'genesis' ) . '…' );
    
    	$button_text = apply_filters( 'genesis_search_button_text', esc_attr__( 'Search', 'genesis' ) );
    
    	$onfocus = "if ('" . esc_js( $search_text ) . "' === this.value) {this.value = '';}";
    	$onblur  = "if ('' === this.value) {this.value = '" . esc_js( $search_text ) . "';}";
    
    	//* Generate ramdom id for the search field (n case there are more than one search form on the page)
    	$form_id = uniqid( 'searchform-' );
    
    	//* Empty label, by default. Filterable.
    	$label = apply_filters( 'genesis_search_form_label', '' );
    	if ( '' == $label )  {
    		$label = apply_filters( 'genesis_search_text', __( 'Search this website', 'genesis' ) );
    	}
    
    	$value_or_placeholder = ( get_search_query() == '' ) ? 'placeholder' : 'value';
    
    	if ( genesis_html5() ) {
    
    		if ( function_exists( 'genesis_a11y' ) ) {
    			$form  = sprintf( '<form %s>', genesis_attr( 'search-form' ) );
    		} else {
    			$form = sprintf( '<form method="get" class="search-form" action="%s" role="search">', home_url( '/' ) );
    		}
    
    		$form .= sprintf(
    				'<meta itemprop="target" content="%s"/><label for="%s">%s</label><input itemprop="query-input" type="search" name="s" id="%s" %s="%s" /><input type="submit" value="%s" /></form>',
    				home_url( '/?s={s}' ),
    				esc_attr( $form_id ),
    				esc_html( $label ),
    				esc_attr( $form_id ),
    				$value_or_placeholder,
    				esc_attr( $search_text ),
    				esc_attr( $button_text )
    		);
    
    	} else {
    
    		$form = sprintf( '<form method="get" class="searchform search-form" action="%s" role="search" >%s<input type="text" value="%s" name="s" id="%s" class="s search-input" onfocus="%s" onblur="%s" /><input type="submit" class="searchsubmit search-submit" value="%s" /></form>', home_url( '/' ), $label, $id, esc_attr( $search_text ), esc_attr( $onfocus ), esc_attr( $onblur ), esc_attr( $button_text ) );
    
    	}
    
    	return apply_filters( 'genesis_search_form', $form, $search_text, $button_text, $label );
    
    }

    https://www.christophherr.com | Genesis Customizations | Buy me a coffee

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble