- This topic has 10 replies, 3 voices, and was last updated 3 years, 11 months ago by David.
-
AuthorPosts
-
May 8, 2020 at 1:49 am #1274951Tim
Hello,
We made 6 different logo’s for headers using elements for our main categories. This works perfectly. We can select where to show. We have 500 categories in our shop and we would like to the subcategories also show the logo of our main category is this possible in a simple way? selecting all pages is not an option with the amount of categories we use.
Thanks in advance!
TimMay 8, 2020 at 9:45 am #1275660TomLead DeveloperLead DeveloperHi there,
So are there only 6 parent categories which different logos, then 500 sub-categories that should inherit the parent logo?
Let me know 🙂
May 8, 2020 at 11:35 am #1275774TimHi Tom
Yes the parent logo of the particular main category should be set for its subcategories
Thanks
TimMay 8, 2020 at 3:59 pm #1276030TomLead DeveloperLead DeveloperYou may be better off using a function in this case instead of Elements.
Will these logos apply to all posts within these categories, and the category archives themselves? Or just the archives?
The logic is likely going to be somewhat complicated, so trying to get a clear picture.
Thanks!
May 8, 2020 at 11:04 pm #1276248TimHi Tom
It will apply only for archive categories as products may appear in different categories.
So for home, product, cart, checkout and normal pages the normal logo should be shown (with 6 dots)
Thanks
TimMay 9, 2020 at 10:09 am #1276995TomLead DeveloperLead DeveloperLet’s give it a shot:
add_filter( 'generate_logo', function( $url ) { $category = get_queried_object(); $category_id = isset( $category->term_id ) ? $category->term_id : ''; if ( is_category( 123 ) || term_is_ancestor_of( 123, $category_id, 'product_cat' ) ) { $url = 'URL TO LOGO FOR CATEGORY ID 123 OR CHILDREN'; } if ( is_category( 456 ) || term_is_ancestor_of( 456, $category_id, 'product_cat' ) ) { $url = 'URL TO LOGO FOR CATEGORY ID 456 OR CHILDREN'; } if ( is_category( 789 ) || term_is_ancestor_of( 789, $category_id, 'product_cat' ) ) { $url = 'URL TO LOGO FOR CATEGORY ID 789 OR CHILDREN'; } // And so on.. return $url; } );
May 11, 2020 at 1:00 am #1278618TimHi tom,
thanks for this!
it does not work yet. i did this to test, but nothing happens to the subcategories of this main category:
https://www.degros.nl/product-categorie/pedicure-groothandel/
add_filter( ‘generate_logo’, function( $url ) {
$category = get_queried_object();
$category_id = isset( $category->term_id ) ? $category->term_id : ”;if ( is_category( 311 ) || cat_is_ancestor_of( 311, $category_id ) ) {
$url = ‘https://www.degros.nl/wp-content/uploads/2020/02/groep-9.svg’;
}return $url;
} );May 11, 2020 at 9:19 am #1279415TomLead DeveloperLead DeveloperAh, just updated the code above to work with product categories: https://generatepress.com/forums/topic/different-logo-each-main-category-subcategories/#post-1276995
May 13, 2020 at 5:01 am #1282244TimWorks like a charm!
Thanks Tom, much appreciated!
May 13, 2020 at 5:38 am #1282300Timhi tom one question, sorry. it does not work for mobile correct? we use mobile header
May 13, 2020 at 8:18 am #1282719DavidStaffCustomer SupportHi there,
you would need to create another function like Tom provided but using this filter:
https://docs.generatepress.com/article/generate_mobile_header_logo/
-
AuthorPosts
- You must be logged in to reply to this topic.