Archived topic
Change Nav Logo For Different Category Pages
25 replies · Started by Bobby on September 20, 2017
Hello Tom,
I have another question. Is it possible to have a different header logo and sticky nav logo for a specific category page?
I have two domain names and I want to redirect one of the domains to a specific category page on my site, but I also want the header logo and sticky nav logo to reflect the second domain's name...in other words, I want the logos on this specific category page to be different from the logos on the rest of the site.
Thanks.
Hi there,
This should help: https://docs.generatepress.com/article/generate_logo/#example
Let me know.
Hi Leo,
I'm a newbie to filters. I know where to put the filter, but can you tell me what/where to add to this filer code to get it to work?? I see where I need to put the category logo url, but where do i specify the category??
add_filter( 'generate_logo','tu_category_logo' );
function tu_category_logo( $logo ) {
// Return our category logo URL
if ( is_category() ) {
return 'URL TO YOUR CATEGORY LOGO';
}
// Otherwise, return our default logo
return $logo;
}
Hello Leo,
I followed the thread all the way through from the link you gave me, but its still not working.
Im using the code Tom provided below.....I placed inside my Simple PHP plugin
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';
}
For example:
add_filter( 'generate_logo', 'generate_category_logo' );
function generate_category_logo()
{
if ( is_category( '357' ) || in_category( '357' ) ) {
return 'http://xyz.com/category-logo.jpg';
}
return 'http://xyz.com/main-site-wide-logo.jpg';
}
Can you double check that the category ID is correct?
If so then try this maybe give this a shot:
add_action( 'after_setup_theme', 'lh_cateory_logo' );
function lh_cateory_logo() {
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';
}
Hi Leo,
I double checked the category id, but it still did not work. I used the new code you provided, but it gave me an error and deactivated my Simple PHP plugin.
I'm wondering....is this code setup for the nav logo? I'm using the nav logo in the "customize >>>layout >>primary-naviagation section.
Thanks.
Oops wrong quotation marks I think:
add_action( 'after_setup_theme', 'lh_cateory_logo' );
function lh_cateory_logo() {
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';
}
Hi Leo,
The code you provided is still not working..it deactivated the Simple PHP plugin again. However, the first code you linked me to that Tom provided...does work, but only with the header logo. It does not work with the navigation logo that im using in the “customize >>>layout >>primary-naviagation section.
Ahh yeah the filter is for the site logo.
Can you link me to the site? I might have a solution.
Try this instead:
add_filter( 'generate_navigation_logo', 'tu_category_logo' );
function tu_category_logo() {
if ( is_category( 'My Category' ) || in_category( 'My Category' ) ) {
return 'URL TO CATEGORY LOGO';
}
return 'URL TO SITE-WIDE LOGO';
}
Hi Tom.
That code did not work. Here's the code im using....
add_filter( 'generate_navigation_logo', 'tu_category_logo' );
function tu_category_logo() {
if ( is_category( '3702' ) || in_category( '3702' ) ) {
return 'http://theballerlife.com/wp-content/uploads/2017/09/baller-wives-life.png';
}
return 'http://theballerlife.com/wp-content/uploads/2016/12/blife1.png';
}
Can you make sure you're using GPP 1.4.3?
Hmmm.... I just updated to the latest version abd its still not working.