Issue
The WordPress theme I'm using applies a home_url() link to the header logo and I'd like to change it to network_home_url()... Easy enough if I am editing the theme files but I'd like to do it via the child theme functions.php file so I can keep all my tweaks separate from the main theme (it's a multisite installation).
This is what I'm working with (albeit simplified):
<div class="logo">
<a href="<?php echo home_url(); ?>">
<img src="/image.png">
</a>
</div>
I've tried the following, which worked but resulted in a site-wide change (including WP settings, etc) which in turn broke all the permalinks:
add_filter('home_url', 'change_logo_link');
function change_logo_link($output) {
return network_home_url();
}
Is there a way I can target that specific hyperlink without editing the parent theme files? I don't think the home_url function is used anywhere else in the theme so it doesn't need to be too specific, I just want to avoid affecting the WP settings.
Thanks in advance!!!
Solution
The concept of child themes is to allow customizing of almost everything without changing the parent theme. Just copy your parent theme's template file with that logo code to your child theme's folder and replace home_url()
with network_home_url()
. WordPress will use that modified child template instead of parent one if you activate this child theme on your network site.
Answered By - Ihor Vorotnov Answer Checked By - David Goodson (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.