How to replace class with an ID for Title Area in Genesis

Posted on Leave a comment
5/5 - (261 votes)

In the members-only forum, a user asked:

Hi All > I’m a bit stuck on using attributes to alter markup.

I’d like to replace the title-area css class with an ID of title-area and I’d rather not rewrite the do_header area.

This can be done using genesis_attr_<context> filter hook.

Add this in child theme’s functions.php:

add_filter( 'genesis_attr_title-area', 'custom_title_area_markup' );
/**
 * Replace `title-area` class with a ID for div.title-area
 *
 * @param array $attributes attributes of HTML element which are assembled into the output.
 * @return attributes of HTML element which are assembled into the output.
 */
function custom_title_area_markup( $attributes ) {
    $attributes['class'] = '';

    $attributes['id'] = 'title-area';

    return $attributes;
}
Leave a Reply

Your email address will not be published. Required fields are marked *