Home › Forums › WoodMart support forum › Display more then one attribute (brands) next to title
Display more then one attribute (brands) next to title
- This topic has 6 replies, 2 voices, and was last updated 4 years, 4 months ago by
Elise Noromit.
-
AuthorPosts
-
October 20, 2020 at 2:00 pm #234784
zurichParticipantHi!
How do I display more than one brand next to the title on a product archive page?
For example I have something like attribute hierarchy as country-> region-> sub-region or audi-> 80-> b3
Now I show it by category, but it doesn’t suit for me because it turns out a very large number of categories, they are difficult to moderateAttachments:
You must be logged in to view attached files.October 20, 2020 at 5:41 pm #234818
Elise NoromitMemberHello,
You can show a label attribute on the product grid. In order to activate the attribute, navigate to Products > Attributes > enter the Brand attribute and enable “Show attribute label on products”.
Best Regards
October 20, 2020 at 6:05 pm #234823
zurichParticipantThank you!
I want to display attributes instead categoriesAttachments:
You must be logged in to view attached files.October 20, 2020 at 8:59 pm #234845
zurichParticipantI used this snippet but don’t like result
Maybe you have more elegant solution?add_action( ‘woocommerce_after_shop_loop_item’, ‘custom_display_post_meta’, 9 );
function custom_display_post_meta() {
global $product;
$attr = array(‘pa_country’, ‘pa_region’,’pa_village’ );
foreach ( $attr as $key=>$attribute ) {
$values = wc_get_product_terms( $product->id, $attribute, array( ‘fields’ => ‘names’ ) );
if (!empty($values))
echo ‘<div class=attr_region><span>’. implode( ‘, ‘, $values ).'</span></div>’;
}
}October 20, 2020 at 10:51 pm #234869
Elise NoromitMemberHello,
Try these steps:
1. Enable showing the attribute on the product page. https://prnt.sc/so0wvn
2. Enable “Show attributes table after short description” in the Theme Settings > Product page > Hide/show elements.
3. Set the Show summary on hover for Hover on product
4. Set “Additional information” for the Hover content in the Theme Settings > Shop page > Product Styles and
Best Regards
October 21, 2020 at 2:02 pm #235059
zurichParticipantThank you!
But it’s not a solution for me, in this case i must change all my products to variable.
In my case i solve it with this snippet, i leave it here if some one need it.
function wc_show_attribute_links() { echo '<div class=wrap_attr>'; global $post; $attribute_names = array( 'pa_attr_slug1', 'pa_attr_slug2','pa_attr_slug3' ); // attribute array foreach ( $attribute_names as $attribute_name ) { $taxonomy = get_taxonomy( $attribute_name ); if ( $taxonomy && ! is_wp_error( $taxonomy ) ) { $terms = wp_get_post_terms( $post->ID, $attribute_name ); $terms_array = array(); if ( ! empty( $terms ) ) { foreach ( $terms as $term ) { $archive_link = get_term_link( $term->slug, $attribute_name ); $full_line = '<a href="' . $archive_link . '">'. $term->name . '</a>'; array_push( $terms_array, $full_line ); } echo '<div class=attr_name><span>'.implode( '<bull_>•</bull_>', $terms_array ).'<bull_>•</bull_></span></div>'; } } } echo '</div>';} add_action( 'woocommerce_shop_loop_item_title', 'wc_show_attribute_links' );
October 21, 2020 at 9:23 pm #235139
Elise NoromitMemberHello,
That is fine. If you have any questions please feel free to contact us.
Best Regards
-
AuthorPosts
- You must be logged in to create new topics. Login / Register