Although overriding the function in a child theme is often a good way to go, it looks like this theme doesn’t set that up with this particular function (because they’re not checking if function_exists()
first, before redefining it – which will cause an error).
However, they have given you a way of overriding it with filters.
At the bottom of their function, everything they return is being run through the cherry_get_site_logo
filter.
Everytime you see apply_filters()
being run in someone else’s code, this is something you can hook into 🙂
To hook into this, you need to add your own filter function. In your function, you can either change their output (eg. through something like str_replace()
or preg_replace()
to replace parts of it), or you can simply ignore what they’ve done and provide your own output (which I understand is what you’re after).
So in this case, to override the output of their function, you just need to:
add_filter("cherry_get_site_logo", "wpse_226159_site_logo");
function wpse_226159_site_logo($logo, $location){
$logo = "This is my overriden logo";
return $logo;
}
This will completely replace their logo output with the text This is my overriden logo
. Obviously replace that with whatever you like.
This code goes in your child theme’s functions.php
file.