Title: Themes: changes related to get_custom_logo() in WordPress 5.5
Author: Stephen Bernhardt
Published: July 28, 2020
Last modified: August 7, 2020

---

 [  ](https://profiles.wordpress.org/sabernhardt/) [Stephen Bernhardt](https://profiles.wordpress.org/sabernhardt/)
10:53 pm _on_ July 28, 2020     
Tags: [5.5 ( 87 )](https://make.wordpress.org/core/tag/5-5/),
[dev-notes ( 650 )](https://make.wordpress.org/core/tag/dev-notes/)   

# Themes: changes related to get_custom_logo() in WordPress 5.5

**Update (August 7)**: Removing the link from the homepage logo will be **optional
for WordPress 5.5**, and a description of how to implement that in themes is now
included below. The CSSCSS Cascading Style Sheets. selector change is still recommended
for some themes.

## Unlinking the custom logo on the homepage

A new `unlink-homepage-logo` parameter is added for the `custom-logo` theme support
option. By default, `unlink-homepage-logo` is set to false, and theme authors can
opt-in for the change by setting it to true. This would be the array for Twenty 
Twenty:

    ```notranslate
    add_theme_support(
    	'custom-logo',
    	array(
    		'height'               => $logo_height,
    		'width'                => $logo_width,
    		'flex-height'          => true,
    		'flex-width'           => true,
    		'unlink-homepage-logo' => true, // Add Here!
    	)
    );
    ```

_If the `unlink-homepage-logo` parameter is set to true, _logo images inserted using`
get_custom_logo()` or `the_custom_logo()` will no longer link to the homepage when
visitors are on that page. In an effort to maintain the styling given to the linked
image, the unlinked logo image is inside a `span` tagtag A directory in Subversion.
WordPress uses tags to store a single snapshot of a version (3.6, 3.6.1, etc.), 
the common convention of tags in version control systems. (Not to be confused with
post tags.) with the same “custom-logo-link” class.

Many themes include both a logo and a site title, and then the logo is decoration
alongside the site title. Because decorative images do not need their purpose to
be described, the unlinked logo’s alt attribute _would be_ empty. In cases where
the site title is not present, the logo alt text may require custom handling. See
code examples below for ways to override the default behavior.

Theme authors who use the `**a**` tag as a CSS selector instead of the `**.custom-
logo-link**` class are encouraged to duplicate their selector to also select the`**
span**` tag, or to directly select the `**.custom-logo-link**` class. A [theme directory search](https://wpdirectory.net/)
found 183 themes that use `**a.custom-logo-link**` for styling.
Please verify whether
this change makes the logo display any differently on the homepage, as well as whether
the empty alt text should be appropriate.

For more details _about the homepage logo link_, see the related ticketticket Created
for both bug reports and feature development on the bug tracker. on TracTrac An 
open source project by Edgewall Software that serves as a bug tracker and project
management tool for WordPress.: [#37011](https://core.trac.wordpress.org/ticket/37011)

## New logo image attributes filterFilter Filters are one of the two types of Hooks 󠀁[https://codex.wordpress.org/Plugin_API/Hooks](https://codex.wordpress.org/Plugin_API/Hooks)󠁿. They provide a way for functions to modify data of other functions. They are the counterpart to Actions. Unlike Actions, filters are meant to work in an isolated manner, and should never have side effects such as affecting global variables and output.

Themes can use the `get_custom_logo_image_attributes` filter to override default
attributes for the logo image or to set additional attributes.

For example, if a theme combines the logo image plus the site title (as actual text)
within a link and/or heading tag, then having the site title as the logo’s alt text
would be redundant. In that case, this is one way to empty the alt text so screen
readers only announce the actual text:

    ```notranslate
    add_filter( 'get_custom_logo_image_attributes', 'my_logo_remove_alt_text', 10, 1 );
    function my_logo_remove_alt_text( $custom_logo_attr ) {
    	$custom_logo_attr["alt"] = "";
    	return $custom_logo_attr;
    }
    ```

To check whether a user has customized the alt text before emptying it, the filter
could be similar to this:

    ```notranslate
    add_filter( 'get_custom_logo_image_attributes', 'my_logo_alt_custom_or_empty', 10, 2 );
    function my_logo_alt_custom_or_empty( $custom_logo_attr, $custom_logo_id ) {
    	$logo_alt = get_post_meta( $custom_logo_id, '_wp_attachment_image_alt', true );
    	if ( empty( $logo_alt ) ) {
    		$custom_logo_attr["alt"] = "";
    	}
    	return $custom_logo_attr;
    }
    ```

If a user has customized the alt text value, this can restore it on the homepage:

    ```notranslate
    add_filter( 'get_custom_logo_image_attributes', 'my_logo_homepage_maybe_alt', 10, 2 );
    function my_logo_homepage_maybe_alt( $custom_logo_attr, $custom_logo_id ) {
    	$logo_alt = get_post_meta( $custom_logo_id, '_wp_attachment_image_alt', true );
    	if ( ! empty ( $logo_alt ) && is_front_page() ) {
    		$custom_logo_attr["alt"] = $logo_alt;
    	}
    	return $custom_logo_attr;
    }
    ```

If the site title is appropriate as a fallback on the homepage in a certain theme,
a filter like this could be used:

    ```notranslate
    add_filter( 'get_custom_logo_image_attributes', 'my_logo_homepage_restore_alt', 10, 2 );
    function my_logo_homepage_restore_alt( $custom_logo_attr, $custom_logo_id ) {
    	$logo_alt = get_post_meta( $custom_logo_id, '_wp_attachment_image_alt', true );
    	if ( is_front_page() ) {
    		if ( ! empty ( $logo_alt ) ) {
    			$custom_logo_attr["alt"] = $logo_alt;
    		} else {
    			$custom_logo_attr["alt"] = get_bloginfo( 'name', 'display' );
    		}
    	}
    	return $custom_logo_attr;
    }
    ```

For more details _about the filter_, see the related ticket on Trac: [#36640](https://core.trac.wordpress.org/ticket/36640)

---

_Props: [@joedolson](https://profiles.wordpress.org/joedolson/) for adding to the
explanation and for review; also [@audrasjb](https://profiles.wordpress.org/audrasjb/),
[@desrosj](https://profiles.wordpress.org/desrosj/), [@williampatton](https://profiles.wordpress.org/williampatton/),
and [@poena](https://profiles.wordpress.org/poena/) for review_

[#5-5](https://make.wordpress.org/core/tag/5-5/), [#dev-notes](https://make.wordpress.org/core/tag/dev-notes/)

### Share this:

 * [  Threads ](https://make.wordpress.org/core/2020/07/28/themes-changes-related-to-get_custom_logo-in-wordpress-5-5/?share=threads)
 * [  Mastodon ](https://make.wordpress.org/core/2020/07/28/themes-changes-related-to-get_custom_logo-in-wordpress-5-5/?share=mastodon)
 * [  Bluesky ](https://make.wordpress.org/core/2020/07/28/themes-changes-related-to-get_custom_logo-in-wordpress-5-5/?share=bluesky)
 * [  X ](https://make.wordpress.org/core/2020/07/28/themes-changes-related-to-get_custom_logo-in-wordpress-5-5/?share=x)
 * [  Facebook ](https://make.wordpress.org/core/2020/07/28/themes-changes-related-to-get_custom_logo-in-wordpress-5-5/?share=facebook)
 * [  LinkedIn ](https://make.wordpress.org/core/2020/07/28/themes-changes-related-to-get_custom_logo-in-wordpress-5-5/?share=linkedin)

 1. ![](https://secure.gravatar.com/avatar/11177b397354c97025f395594f49e10041be4497df46e5d8b1f5b7ca4b063a3a?
    s=32&d=mm&r=g)
 2.  [Phil Johnston](https://profiles.wordpress.org/johnstonphilip/)  12:07 am _on_
    July 29, 2020
 3. Do I understand correctly that this
     change will knowingly break at least 183 themes
    on the WordPress theme repo alone, and requires manual updates for each theme to
    fix?
 4.  * ![](https://secure.gravatar.com/avatar/d401f6723c24ce90038075be6a7990d02d2d7480fa3735f3697832fe393557d5?
       s=32&d=mm&r=g)
     *  [williampatton](https://profiles.wordpress.org/williampatton/)  12:25 am _on_
       July 29, 2020
     * It looks like 183 themes from the repo will be affected by it. That’s not to
       say that they are all going to be broken. Do you have an alternative proposal
       that can achive the same thing but without any changes with implications for
       theme developers? I would very much welcome it if you have one.
        - ![](https://secure.gravatar.com/avatar/11177b397354c97025f395594f49e10041be4497df46e5d8b1f5b7ca4b063a3a?
          s=32&d=mm&r=g)
        -  [Phil Johnston](https://profiles.wordpress.org/johnstonphilip/)  1:50 pm
          _on_ July 29, 2020
        - Could it be simply left the way it is? Was there research done to indicate
          this was high enough of a positive impact to be justified?
        - ![](https://secure.gravatar.com/avatar/8013a62d7397c006bae48b96d6832a573ea71a7d5d3597fe584210567b508c05?
          s=32&d=mm&r=g)
        -  [Justin Tadlock](https://profiles.wordpress.org/greenshady/)  1:50 pm _on_
          July 29, 2020
        - I have an alternative proposal. Make use of the “theme supports” system to
          take care of this. There is precedent for breaking HTMLHTML HyperText Markup
          Language. The semantic scripting language primarily used for outputting content
          in web browsers. changes when coreCore Core is the set of software required
          to run WordPress. The Core Development Team builds WordPress. made the switch
          to HTML5 for various elements in the past. I’d use something like `add_theme_support('
          unlink-homepage-logo' )` (or some other better name) for themes to opt into
          the feature.
           * ![](https://secure.gravatar.com/avatar/8013a62d7397c006bae48b96d6832a573ea71a7d5d3597fe584210567b508c05?
             s=32&d=mm&r=g)
           *  [Justin Tadlock](https://profiles.wordpress.org/greenshady/)  1:54 pm
             _on_ July 29, 2020
           * It might not hurt to introduce a flag for any breaking HTMLHTML HyperText
             Markup Language. The semantic scripting language primarily used for outputting
             content in web browsers. changes now and in the future. Something along
             the lines of `add_theme_support( 'html-compat', [ 'logo-link', 'some-other-
             change' ] )`.
           * This might have saved us from some other HTML changes like the recent 
             calendar HTML changes.
              - ![](https://secure.gravatar.com/avatar/11177b397354c97025f395594f49e10041be4497df46e5d8b1f5b7ca4b063a3a?
                s=32&d=mm&r=g)
              -  [Phil Johnston](https://profiles.wordpress.org/johnstonphilip/)  2:
                08 pm _on_ July 29, 2020
              - I like that!
              - ![](https://secure.gravatar.com/avatar/d401f6723c24ce90038075be6a7990d02d2d7480fa3735f3697832fe393557d5?
                s=32&d=mm&r=g)
              -  [williampatton](https://profiles.wordpress.org/williampatton/)  10:
                41 pm _on_ July 29, 2020
              - Yeah good call on that. I will open a tracTrac An open source project
                by Edgewall Software that serves as a bug tracker and project management
                tool for WordPress. ticketticket Created for both bug reports and feature
                development on the bug tracker. based on this idea. Thanks for flagging
                this both of you 🙂
                 * ![](https://secure.gravatar.com/avatar/11177b397354c97025f395594f49e10041be4497df46e5d8b1f5b7ca4b063a3a?
                   s=32&d=mm&r=g)
                 *  [Phil Johnston](https://profiles.wordpress.org/johnstonphilip/)
                   12:02 pm _on_ July 30, 2020
                 * [@williampatton](https://profiles.wordpress.org/williampatton/) 
                   Thank you!
                    - ![](https://secure.gravatar.com/avatar/6f505c6be9a951929a99becb6b413dcfa583a5ca3dd0f7320766fee1481f0f82?
                      s=32&d=mm&r=g)
                    -  [Jb Audras](https://profiles.wordpress.org/audrasjb/)  1:44 
                      pm _on_ July 30, 2020
                    - Hi there,
                    - Those are very relevant thoughts. Thank you.
                       I added a proposal
                      to patchpatch A special text file that describes changes to code,
                      by identifying the files and lines which are added, removed, 
                      and altered. It may also be referred to as a **diff**. A patch
                      can be _applied_ to a codebase for testing. this backwards compatibility
                      issue in the related ticketticket Created for both bug reports
                      and feature development on the bug tracker.: [https://core.trac.wordpress.org/ticket/37011#comment:32](https://core.trac.wordpress.org/ticket/37011#comment:32)
                    - Cheers,
                       Jb
 5. ![](https://secure.gravatar.com/avatar/d401f6723c24ce90038075be6a7990d02d2d7480fa3735f3697832fe393557d5?
    s=32&d=mm&r=g)
 6.  [williampatton](https://profiles.wordpress.org/williampatton/)  7:55 am _on_ July
    29, 2020
 7. +make.wordpress.org/themes/

Comments are closed.

# Post navigation

[← Editor Chat Agenda: 29 July, 2020](https://make.wordpress.org/core/2020/07/28/editor-chat-agenda-29-july-2020/)

[Miscellaneous Developer Focused Changes in WordPress 5.5 →](https://make.wordpress.org/core/2020/07/29/miscellaneous-developer-focused-changes-in-wordpress-5-5/)