• Skip to primary navigation
  • Skip to main content
OsomCode

OsomCode

Awesome code tutorials for WordPress and Genesis

  • Subscribe
  • My account
    • Edit profile
    • Favorites
    • Update credit card
  • Login

Setting a different favicon than the logo in a WordPress block theme

Discover in this tutorial how to use an image other than the site logo as favicon in a WordPress theme.

By default, in block themes the favicon uses the same image as the site logo. This is fine when the logo is square, but if it’s elongated you’ll probably want to be able to choose another version of the icon that is square to be displayed as the favicon.

Here are two ways to achieve this.

Options to set a favicon different from the site logo in a WordPress block theme

Option A

To see this and another 1097 code snippets of this website, login or subscribe here.

Option B

Add the following code at the end of functions.php or in your functionality plugin:

To see this and another 1097 code snippets of this website, login or subscribe here.

In this code you use the wp_head hook to enter the URL of the image you want to use as favicon.

Just replace icon_url with the URL where the icon you want to use as favicon is located.

Remember that this must be square and with a minimum of 512 x 512 pixels.

Conclusion

Now you know how to set a favicon different from the site logo in a WordPress block theme with a little bit of code. This solution will come in handy when the site logo is elongated and you can choose another version of the icon that is square.

If you have any question, please leave it in the comments. And if you want to give me a suggestion for future snippets, please send it through the contact form.

Benefits of being a subscriber. 🙂

PHP WordPress

To leave read and make questions about this code, you can login or register.

  • About OsomCode
  • FAQ
  • Contact

Legal Notice · Privacy Policy · Cookie Policy · Terms and conditions
Copyright © 2026

close-icon

Lost your password?