Archived topic
Need to set a different URL for each different header logo
20 replies · Started by Rachael on June 18, 2018
The code is correct BUT not for subpages. It is quite more difficult to loop through all subpages. But try the code from https://developer.wordpress.org/reference/functions/is_page/ (down at the bottom Snippet 4) or you use get_post_ancestors($post).
Maybe this will help you as well: https://wordpress.stackexchange.com/questions/169306/check-if-is-on-child-page-of-a-particular-page
Is erg-services a category?
If so we might be able to do this:
add_filter( 'generate_logo_href','generate_add_custom_logo_href' );
function generate_add_custom_logo_href()
{
if ( in_category( 'erg-services' ) ) {
return 'http://test.ergapc.co.uk/erg-services/';
}
return 'http://test.ergapc.co.uk/';
}
Thank you I will try that out Heiko. No Leo, it is not a category. It is a top level page. I'll let you know the result!
If Heiko's method doesn't work then you might need to consider making it into a category so there is actually relationship outside the menu items :)
It would make a bit more sense too.
Because all of the logo links were working apart from on the Group page, I disabled the link on the Group logo. It is a landing page and does not have any child pages so it doesn't actually need to link anywhere. So it's all set. Thank you for all of your help!
Awesome.
Glad you found a solution!