Code to change your logo link in the GeneratePress WordPress theme
Maybe you have a landing page on an external domain and want the logo to take visitors to another website instead of your landing page’s home. You can do it very easily, without a specific plugin, just by adding a few lines of code to your WordPress PHP.
This is particularly useful if you manage several domains or projects and want to unify navigation between them.
Best of all, you can make this change quickly without installing any extra plugin. You only need to add a few lines of code to your WordPress functions.php file, although you can also use a general code snippets plugin, which will be very handy for this and other tasks.
There are 2 ways to change the logo link in WordPress and GeneratePress
Directly from the Theme File Editor
Go to Appearance > Theme File Editor in the WordPress dashboard. There, find the functions.php file of your active theme and add the code. However, before doing this it’s highly recommended to install a GeneratePress child theme. This is crucial so your changes aren’t lost when the parent theme is updated. A child theme lets you keep custom code without compatibility issues or data loss.
Using a plugin such as Code Snippets
Another simple and safer way to add PHP code to WordPress is with a plugin such as Code Snippets. This kind of plugin lets you add PHP snippets without editing the theme files directly. It’s a safer option because it minimises the risk of errors affecting your site. And because changes are handled by a plugin, you can deactivate or edit the code at any time without touching functions.php, which gives you more flexibility and control.
The code to add to WordPress to change your logo link
add_filter( 'generate_logo_href', function() {
return 'https://wanderlustmenorca.com';
} );Security considerations
When you change your site’s PHP code, make sure the changes are compatible and don’t cause conflicts with other plugins or features. I strongly recommend backing up your WordPress before modifying any code. That way, if something goes wrong, you can always restore the previous version of the site without losing any content or settings.
With these simple steps you can customise how your logo behaves in GeneratePress and send users to the website that suits you best, improving navigation and aligning it with your business goals.




