WordPress.org

Ready to get started?Download WordPress

Forums

Quark
[resolved] No alt tag on header image (4 posts)

  1. RolandOfEld
    Member
    Posted 8 months ago #

    hi

    ive noticed that my site and also the the quark theme website do not have any alt tags showing against the header image.

    I came across this while trying to optimize my site for SEO.. it appears that the alt tag is empty on the header image..

    is there anyway to rectify this?

    P.S i also noted that the header image is wrapped in a H1 tag... is that neccassary as the main content headers should be H1's?

  2. linux4me2
    Member
    Posted 8 months ago #

    Yes, the best way to fix the issue with the empty alt attribute is to first create a child theme, so that your changes won't be overwritten when the theme is updated.

    Next, download the header.php file from the parent theme to your PC, and open it in a text-only editor like Notepad. Look for this line on about line 53 of the file:
    <img src="<?php header_image(); ?>" height="<?php echo get_custom_header()->height; ?>" width="<?php echo get_custom_header()->width; ?>" alt="" />
    You can see that the alt attribute is in there, it's just empty. To fix it, I suggest replacing that line with the following:
    <img src="<?php header_image(); ?>" height="<?php echo get_custom_header()->height; ?>" width="<?php echo get_custom_header()->width; ?>" alt="<?php echo get_bloginfo('name'); ?>" />
    That will populate the alt attribute for the header image with the title of your site.
    Once you've done that, save the file and upload it to the child theme folder you created, then activate the child theme in WordPress Admin Appearance -> Themes and you should be good to go.

    It's not unusual for developers to leave the header image inside the H1 tags, simply because it's easier to code it that way to accommodate sites that might use a text-only header rather than an image. It's not perfect coding practice, but as far as I know, it doesn't do any harm.

  3. ahortin
    Member
    Theme Author

    Posted 8 months ago #

    As @linux4me2 kindly pointed out, simply make a copy of header.php and add it to your child theme and then add in the ALT tag that you want to use.

  4. RolandOfEld
    Member
    Posted 8 months ago #

    thanks guys :D

Reply

You must log in to post.

About this Theme

About this Topic

Tags

No tags yet.