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