Site logo

Archived topic

Help Needed - Would like to show different header logo in category

11 replies · Started by itg on August 5, 2016

Viewing posts 1–12 of 12

Hi, i hope you can help, i have created a new category and would like to dispaly a different header logo for the new category only, how would i go about this please.

You could try a function like this:

add_filter( 'generate_logo', 'generate_category_logo' );
function generate_category_logo()
{
    if ( is_category( 'My Category' ) || in_category( 'My Category' ) ) {
        return 'URL TO CATEGORY LOGO';
    }

    return 'URL TO SITE-WIDE LOGO';
}

Adding PHP: https://generatepress.com/knowledgebase/adding-php-functions/

Hi Tom i used this code, and the logo does not show, just blank - Any ideas

<?php
/**
* All of your custom PHP can go in this file below this commented area
* Caution: Be sure to have access to your server via File Manager or FTP in case an error occurs
* Happy editing!
*/

add_filter( 'generate_logo', 'generate_category_logo' );
function generate_category_logo()
{
if ( is_category( '565' ) ) {
return 'http://www.mywebsite.com/wp-content/uploads/2016/08/house-clearance-logo.jpg';
}

return $logo;
}

ok logo is showing on actual category page so no problem here,

but any post within the said category is showing no logo just a blank on the actual post page, thank you

Just checked the rest of the site tom and all pages and posts blank no logo what so ever

Hi Tom using this code below - the new logo does appear in the category but not the posts under that category but again the regular logo has disappered site wide

I cleared cache each time, so not seeing cached versions
=============
add_filter( 'generate_logo', 'generate_category_logo' );
function generate_category_logo()
{
if ( is_category( '565' ) ) {
return 'http://www.mywebsite.com/wp-content/uploads/2016/08/house-clearance-logo.jpg';
}

return 'URL TO SITE-WIDE LOGO';
}
=============================

You'll want to replace "URL TO SITE-WIDE LOGO" with the URL to the logo you want to show up on all other pages.

Hi Tom, thanks for all your help nearley there, all working exellent now except new logo not showing in posts under given category.

The new logo is showing on the actual category page but any posts within that category are showing the default old logo, thanks Tom

add_filter( 'generate_logo', 'generate_category_logo' );
function generate_category_logo()
{
if ( is_category( '565' ) ) {
return 'http://www.mywebsite.com/wp-content/uploads/2016/08/house-clearance-logo.jpg';
}

return 'http://www.mywebsite.com/wp-content/uploads/2016/08/itg-logo.jpg';
}

I've adjusted my code above to include it even if we're inside a post in that category.

WOW Thanks Tom all fixed, many thanks.

You're welcome :)

This archived topic is closed to new replies.