Wednesday, 15 January 2014

How to replace instance of WordPress home_url hyperlink via functions.php -


I apply a home_url () link to the header logo I am using WordPress theme and I want to change it Network_home_url () ... if I am editing theme files, then it is easy enough, but I want to do it through child theme functions.php file so that I change all my changes to the main theme (this is a multisite installation ).

This is what I'm working with (though simplified):

  & lt; Div class = "logo" & gt; & Lt; A href = "& lt ;? php echo home_url () ;? & gt;" & Gt; & Lt; Img src = "/ image.png" & gt; & Lt; / A & gt; & Lt; / Div & gt;  

I tried the following, which worked but broke all permalinks in return for the result of site-wide changes (WP settings, etc.):

  add_filter ('home_url', 'change_logo_link'); Function change_logo_link ($ output) {return network_home_url (); }  

Is there any way that I can target that specific hyperlink without editing parent theme files? I do not think the home_url function is used somewhere in the theme so it does not need to be very specific, I just want to avoid affecting WP settings.

Thanks in advance thanks! home_url () with network_home_url () .

If you activate this network theme on your network site, then WordPress will use that modified hair template instead of parent.


No comments:

Post a Comment