• 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

Modify the link URL of a logo image in WordPress

Learn in this tutorial how to customize the URL to which an image logo links in WordPress.

Following a request from a subscriber, I prepared a tutorial on how to change the link of a text logo.

But as I commented on it, to get the same effect with a logo in image format you have to use a different code.

So in this tutorial you are going to see how to modify the link in an image logo thanks to a WordPress filter.

Snippet to change the link URL in an image logo for a WordPress theme

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

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

Thanks to the get_custom_logo filter you can modify the link pointing to a logo in image format.

In this example the URL is “https://www.yourwebsite.com”, but the idea is that you replace it with a custom one that fulfills the function you want.

Logo image type
Logo image type

Note: this strategy of modifying the URL with the get_custom_logo filter only works if you are using an image as the logo.

If you are using a logo in text format you need to apply this Genesis filter.

Surprising, isn’t it?

To achieve the same result, the method is very different if the logo is text or image.

So much so that in one case you must use a general WordPress filter and in the other a specific Genesis one.

Conclusions

Now you know how to modify the URL of the link to which the logo redirects when it is an image in a WordPress theme.

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. 🙂

Genesis Framework Header PHP

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 © 2023

Lost your password?