studiopress / genesis-sample

This is the sample theme created for the Genesis Framework.
https://demo.studiopress.com/genesis-sample/
528 stars 285 forks source link

Author Box Title – Change H4 to H2 #411

Closed DecorOutdoor closed 4 weeks ago

DecorOutdoor commented 1 month ago

The author box title displayed on single posts has an H4 tag, which Google Pagespeed Insights has cited “Heading elements are not in a sequentially-descending order.”

The developers for the Genesis Sample theme edited the author archives to address this issue per updates: “Accessibility: Author box titles on author archives now use h2 instead of h4 to prevent heading levels from jumping.”

However, they did not address this on single posts, which are much more important (and indexed by Google).

The developers did offer some coding for the child theme’s functions.php file (see below).

add_filter('genesis_author_box_title', 'custom_author_box_title', 10, 3);function custom_author_box_title($title, $context, $user_id) { // Always use

for the author box title return '

' . $title . '

';}

But it only added a new H2 within the original H4 header tags rather than replacing them (see below).

About Bill Ferris

Any help would be greatly appreciated.

Here is an example of the author box title issue: [https://decoroutdoor.com/blog/how-to-clean-patio-umbrella/]

dreamwhisper commented 4 weeks ago

@DecorOutdoor I don't work for WPE, but saw this in passing. Hopefully, it will help you.

add_filter( 'genesis_author_box', 'custom_genesis_author_box', 10, 6 );
/**
 * Genesis 'genesis_author_box' filter.
 *
 * Change the title element from H1 to H2.
 *
 * @param string $output the initial author box html.
 * @param string $context the current context.
 * @param string $pattern (s)printf pattern.
 * @param string $gravatar the gravatar html.
 * @param string $title the title.
 * @param string $description the author description.
 * @return string final author box html.
 */
function custom_genesis_author_box( $output, $context, $pattern, $gravatar, $title, $description ) {

    $pattern  = sprintf( '<section %s>', genesis_attr( 'author-box' ) );
    $pattern .= '%s<h2 class="author-box-title">%s</h2>';
    $pattern .= '<div class="author-box-content" itemprop="description">%s</div>';
    $pattern .= '</section>';

    $output = sprintf( $pattern, $gravatar, $title, $description );

    return $output;

}
DecorOutdoor commented 3 weeks ago

Thanks!

I think that did it Regards,

Bill Ferris 773.383.9645 | @. @.> Decor Outdoor | 5828 Colfax Avenue #7, North Hollywood CA 91601 888.281.8941 | @. @.> https://www.facebook.com/decoroutdoorcom/ https://www.instagram.com/decoroutdoorcom/ https://twitter.com/decoroutdoorcom https://www.pinterest.com/decoroutdoorcom/ https://www.houzz.com/pro/decoroutdoorcom/decor-outdoor

On Jun 5, 2024, at 8:55 AM, Jen Baumann @.***> wrote:

@DecorOutdoor https://github.com/DecorOutdoor I don't work for WPE, but saw this in passing. Hopefully, it will help you.

add_filter( 'genesis_author_box', 'custom_genesis_author_box', 10, 6 ); /**

  • Genesis 'genesis_author_box' filter.
  • Change the title element from H1 to H2.
  • @param string $output the initial author box html.
  • @param string $context the current context.
  • @param string $pattern (s)printf pattern.
  • @param string $gravatar the gravatar html.
  • @param string $title the title.
  • @param string $description the author description.
  • @return string final author box html. */ function custom_genesis_author_box( $output, $context, $pattern, $gravatar, $title, $description ) {

    $pattern = sprintf( '<section %s>', genesis_attr( 'author-box' ) ); $pattern .= '%s

    %s

    '; $pattern .= '
    %s
    '; $pattern .= '';

    $output = sprintf( $pattern, $gravatar, $title, $description );

    return $output;

} — Reply to this email directly, view it on GitHub https://github.com/studiopress/genesis-sample/issues/411#issuecomment-2150415855, or unsubscribe https://github.com/notifications/unsubscribe-auth/BIWY24A3B4Z6IWFT2DEXQZDZF4YGTAVCNFSM6AAAAABIIAUFEKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNJQGQYTKOBVGU. You are receiving this because you were mentioned.