Home › Forums › WoodMart support forum › Show brand image on taxonomy page?
Show brand image on taxonomy page?
- This topic has 11 replies, 2 voices, and was last updated 2 years, 12 months ago by
Elise Noromit.
-
AuthorPosts
-
February 18, 2022 at 10:55 am #354192
ThoraParticipantHello,
I want to show the brand image on the taxonomy page (changed “woocommerce/archive-product.php”, saved as “woocommerce/taxonomy-brands.php”), where the brand image on the single product page links to.
I tried several codes like this one (for testing purpose as a simple echo without IMG tag):
<?php $term = get_queried_object(); $taxonomymetafield = get_field('image', $term); echo $taxonomymetafield; ?>
On the page in the browser I don’t see the brands URL, but only the text “Array”.
I also searched the template and core plugin for the code, that embeds the brands image on the single product page, but couldn’t find it, in order to adapt it.
February 18, 2022 at 11:22 pm #354349
Elise NoromitMemberHello,
If I follow you well you want to show the brands grid (image grid leading to each brand appropriately) on the shop page, if so, enable archives in the Brand attribute, create HTML block and add Brand widget/element: https://xtemos.com/docs-topic/html-blocks-usage/ and https://xtemos.com/docs-topic/elements-and-widgets/
Then follow these steps:
1. Enable Top filters in the Theme Settings >Product archives > Shop filters https://gyazo.com/3564df2a5d658a0010b6c0ebd0b537d4
2. Enable Shop filters area always opened
3. Shop filters content type should be set Custom content
4. You can choose the HTML block with the content from the Shop filters custom content drop-down.
You will have all brand images on the shop page and all product page in the place where you see this banner: https://woodmart.xtemos.com/product-category/furniture/?demo=
If you want to show this block on shop page only, you can do that by means of the Theme settings presets: https://xtemos.com/docs-topic/theme-settings-presets/
If you have any questions please feel free to contact us.
Best Regards
February 21, 2022 at 7:47 am #354722
ThoraParticipantHello Elisa,
no, I want to display only the one brand image on the page, where all the products of one brand are listed, e.g.:
https://woodmart.xtemos.com/shop/?filter_brand=rosenthalI have created a template file for these pages (in this case it would be “woocommerce/taxonomy-pa_brand.php”, sorry, I forgot the “pa_” in my first posting), where I could add the needed code above the products.
But the code from my first posting doesn’t work – it does only show the text “Array” instead of the image URL, as described above. And I couldn’t find a code in the original template files, that adds the brand image e.g. on the single product page, to adapt this.
February 21, 2022 at 11:59 pm #354939
Elise NoromitMemberHello,
If you want one category to show one brand image leading to the brand page, you need to create different HTML blocks for different categories and either set them by means of the presets: https://xtemos.com/docs-topic/theme-settings-presets/
So, first of all, you follow all the steps I listed in #354349, then you create as many HTML blocks as many categories you have and you create a separate rule for every category and insert separate HTML blocks.
As the result, when you visit T-shirt, you will have a brand for this category, that category would have its own brand.
Or you can insert each HTML block into the Product category description: https://xtemos.com/docs-topic/html-blocks-usage/ The difference would be the location.
If you have any questions please feel free to contact us.
Best Regards
February 22, 2022 at 7:23 am #355006
ThoraParticipantHello Elise,
no, we don’t want to show a brand image on the category page, but on top of the filtered brand archive page, as the example page I linked in my last post:
https://woodmart.xtemos.com/shop/?filter_brand=rosenthalWe want to setup this via PHP template as described in the first post, because we don’t want to create attribute descriptions for every 300 brands, when we could implement this with one template for all (woocommerce/taxonomy-pa_brand.php) because of the wanted unified appearance.
I would have liked to implement this without using support, unfortunately I haven’t found any PHP code that works, although the descriptive text sounds like that’s what it’s all about. Maybe there is just a small error in the code of my first post?
February 23, 2022 at 9:55 am #355301
Elise NoromitMemberHello,
WoodMart theme does not have an option to insert the content on the brand page. The Brand is the Woocommerce attribute.
You use Advanced Custom Fields please contact this plugin support perhaps they would suggest you the solution.
Best Regards
February 24, 2022 at 7:26 am #355689
ThoraParticipantHello,
but the attribute image is a theme feature by Woodmart and not by WooCommerce or ACF.
I would like to understand or know, why the mentioned code doesn’t work and what do I have to change to make it work.
Because as already said, I don’t find the code in the original Woodmart files, that embeds the brand image in the single product page – I was hoping, I could adapt this.February 25, 2022 at 2:01 pm #356018
Elise NoromitMemberHello,
I am a bit confused. Initially, you wrote about “show the brand image on the taxonomy page” Please clarify in detail your purpose. Please provide the link and screen what you want to show.
Best Regards
February 28, 2022 at 7:31 am #356364
ThoraParticipantHello,
it is possible to add a custom template for e.g. the brand taxonomy archives with:
a) activating archives in the “brand” settings (and re-saving global WordPress Permalinks settings) and
b) building a new template file “woocommerce/taxonomy-pa_brand.php” (e.g. by copying “woocommerce/archive-product.php”)Then the brand image on single product pages doesn’t link to:
https://woodmart.xtemos.com/shop/?filter_brand=rosenthal
But to the nice permalink:
https://woodmart.xtemos.com/brand/rosenthal/In the attachment you can see an edited screenshot of https://woodmart.xtemos.com/shop/?filter_brand=rosenthal with added title (which works fine in the development environment) and added brand image (which I can’t get to work).
Attachments:
You must be logged in to view attached files.March 1, 2022 at 12:34 pm #356630
Elise NoromitMemberHello,
Please add this code to the functions.php of the child theme:
add_action( 'woocommerce_archive_description', function () { if ( woodmart_is_product_attribute_archive() ) { $queried_object = get_queried_object(); if ( $queried_object && property_exists( $queried_object, 'term_id' ) ) { $image = get_term_meta( $queried_object->term_id, 'image', true ); if ( isset( $image['id'] ) ) { echo wp_get_attachment_image(get_term_meta( $queried_object->term_id, 'image', true )['id']); } echo '<h3>All products by ' . $queried_object->name . '</h3>'; } } }, 10 );
If you have any questions please feel free to contact us.
Best Regards
March 1, 2022 at 1:36 pm #356656
ThoraParticipantThank you very much, now it does work!
I only added a
, 'full'
to get the full size image and not the (default) thumbnail size, that is a cropped size:add_action( 'woocommerce_archive_description', function () { if ( woodmart_is_product_attribute_archive() ) { $queried_object = get_queried_object(); if ( $queried_object && property_exists( $queried_object, 'term_id' ) ) { $image = get_term_meta( $queried_object->term_id, 'image', true ); if ( isset( $image['id'] ) ) { echo wp_get_attachment_image(get_term_meta( $queried_object->term_id, 'image', true )['id'], 'full'); } echo '<h3>All products by ' . $queried_object->name . '</h3>'; } } }, 10 );
March 2, 2022 at 1:01 am #356773
Elise NoromitMemberWe are always happy to help you, write to us when you have any difficulties or issues with our theme.
We would be grateful for your rate and feedback on http://themeforest.net/downloads in case you are satisfied with our theme and customer service
Thank you in advance!
Wish you a wonderful day!
-
AuthorPosts
- You must be logged in to create new topics. Login / Register