Archived topic
Change Header Logo
13 replies · Started by Guido Wenzl on October 14, 2015
Hi,
I want to display a different header logo on specific pages inside my Wordpress Installation.
Is this possible? I know it is possible with Blog Header, but I do not find a way to change the header logo.
Thanks.
Hi there,
I explained one method that can accomplish this here: https://generatepress.com/forums/topic/change-site-header-and-title-based-on-page/#post-111841
Let me know if you need more info :)
That's a great solution Tom :)
Yes, it looks like a perfect solution, but I am getting an error.
On the page with the custom header it does show both logos side by side. All the other pages stay with the default logo.
What am I doing wrong because I followed every line from you solution?
It is working now . I made the mistake by not removing the logo in the GP settings.
Thanks!
No problem! Glad I could help :)
Hi Tom,
is there a way to change the footer text in the same way?
Best regards,
Guido
You want to change the footer content on a per-page basis?
Yes. The same I did with The Header.
1. Remove the default copyright with this function: https://gist.github.com/generatepress/36c0c52479679252af28 (https://generatepress.com/knowledgebase/adding-php-functions/)
2. Now look for the "Custom Fields" metabox – click "Enter new".
3. Under "Name", add: custom_footer
4. Under "Value", enter your copyright message
5. Now in GP Hooks, in the "Before Footer Content" hook, add this:
<?php
global $post;
$copyright = get_post_meta($post->ID, 'custom_footer', true);
if ( ! empty( $copyright ) ) : ?>
<?php echo $copyright; ?>
<?php else : ?>
My default copyright message
<?php endif; ?>
Be sure to check the "Execute PHP" checkbox.
Something like that should do the trick :)
Hi Tom,
I want to have the (changing) logo in the header clickable with a link. Is this also possible? How to achieve this?
Thanks
Guido
Do you want the same link for every image? Or does each image need a separate link?
If it is possible it would be good to have different links with different logos.
You would follow the same process as above to add a custom field for the link:
1. In the “Custom Fields” metabox – click “Enter new”.
2. Under “Name”, add: custom_link
3. Under “Value”, enter your link URL
4. In GP Hooks, in the “Before Header Content” hook, change the code to this to wrap the image in an anchor tag:
<?php
global $post;
$image = get_post_meta($post->ID, 'custom_header', true);
$link = get_post_meta($post->ID, 'custom_link', true);
if ( ! empty( $image ) ) : ?>
<a href="<?php echo $link; ?>"><img src="<?php echo $image; ?>" alt="" /></a>
<?php else : ?>
<img src="URL TO MY DEFAULT LOGO" alt="" />
<?php endif; ?>
