You are not using all possibilities of the get_custom_logo
filter. As you can see from the source not only the $html
is passed to it, but also the $blog_id
. You can use the latter to do a preg_replace
on the link like this:
add_filter ('get_custom_logo','wpse305624_change_logo_link',10,2);
function wpse305624_change_logo_link ($html,$blog_id) {
$homelink = get_home_url ();
$bloglink = get_permalink ($blog_id); // or anything else, for instance the blogs's parent
$html = preg_replace ($homelink,$bloglink,$html);
return $html;
}
By the way, you could also use the filter on get_theme_mod
(called at the beginning of get_custom_logo
) to modify the returned image id in the first place, so you don’t have to do a preg_replace
afterwards. Unfortunately I don’t see a similarly elegant way to manipulate the url.