-
AuthorPosts
-
May 24, 2020 at 10:04 am #1215674
Hello!
I’m looking for solution to show attribute (taxonomy) inside Masonry Products.
It’s difficult to find because with this topic (in this forum) it always is suggested to h_ire a d_eveloper.
At the end, I think that I found a solution that works for me, and can share for others users.—
Show Brand name in Masonry Product,
add this code in ChildTheme’s “functions.php” file:/* ADD BRAND on MASONRY SHOP */ add_filter( 'avf_masonry_loop_prepare', 'avf_masonry_brand', 10, 2 ); function avf_masonry_brand( $key, $entries ) { $id = $key['ID']; if($key['post_type'] == 'product') { $brands = wp_get_object_terms( $id, 'pwb-brand', array( 'fields' => 'names' ) ); foreach( $brands as $brand ){ $output .= '<h6 class="brand" title="BRAND">'. $brand .'</h6>'; } } $key['text_after'] .= trim( $output ); return $key; }
Please, can you tell me if is possible to show under prodcut title, over price?
(now appears under price)Thanks in advance.
Best Regards!- This topic was modified 4 years, 6 months ago by abeldb.
May 27, 2020 at 4:44 pm #1217022Hey abeldb,
Thank you for the inquiry.
Try to append the output to the the_title key — find this line..
$key['text_after'] .= trim( $output );
.., then replace it with:
$key['the_title '] .= trim( $output );
Let us know if that helps.
Best regards,
IsmaelMay 27, 2020 at 6:17 pm #1217095Wow, perfect!
Thank you very much!!—
Ummm, for future users, take care, extra space after tittle must be deleted
$key['the_title'] .= trim( $output );
May 27, 2020 at 9:51 pm #1217148Hi,
Did you need additional help with this topic or shall we close?
Best regards,
Jordan ShannonMay 28, 2020 at 9:46 am #1217285Hi Jordan!
Sorry, yes allright!!
Best regards,
—
For other users,
code to show tax category on masonry products:
(add on ChidTheme functions.php file)/* SHOW PRODUCT CAT on MASONRY */ add_filter( 'avf_masonry_loop_prepare', 'avf_masonry_cat', 10, 2 ); function avf_masonry_cat( $key, $entries ) { $id = $key['ID']; if($key['post_type'] == 'product') { $cats = wp_get_object_terms( $id, 'product_cat', array( 'fields' => 'names' ) ); foreach( $cats as $cat ){ $output .= $cat .' '; } } $key['the_title'] .= trim( '<h6 class="cat">'. $output .'</h6>'); return $key; }
May 28, 2020 at 7:17 pm #1217486Hi,
Thank you for sharing the solution! If you need help with anything else, please let us know here in the forums.
Best regards,
Jordan Shannon -
AuthorPosts
- The topic ‘Masonry Products show attribute (tax) Brand’ is closed to new replies.