I got a snippet that is showing attributes of my product on the archive page as shown in the picture. At some results there are a lot of results and i want to limit that to let's say 5 and after 5 maybe a show more button. The piece of code i use now is down below. I would like to have it separated as well that it only targets one attribute and not all.
Not an expert in PHP so i'm struggling to find a resolution.
add_action( 'woocommerce_shop_loop_item_title', 'add_motorcode' );
function add_motorcode() {
global $product;
echo wc_display_product_attributes ( $product );
}
I've tried to select the brand by itself it worked but the clickable attribute was gone.
add_action( 'woocommerce_shop_loop_item_title', 'fdev_display_attribute_brand', 10 );
function fdev_display_attribute_brand() {
global $product;
$taxonomy = 'pa_merk';
if ( ! $product->get_attribute($taxonomy) ) {
return;
}
echo '<div class="wc-attribute-brand" style="margin-top: 20px;"><span style="font-size:16px; font-weight:600;">' . __( 'brand : ', 'woocommerce' ) ;
echo '<p class="attribute-brand">' . $product->get_attribute($taxonomy) . '</p> </span> </div>' ;
}
Anyone that could push me in the right direction?
i not found solution for limit this thing but i found source of this function HERE
SO i rebuild this function
Step1: first of all i Changed the name function!!!
Step2: add
$limitation = -1paramStep3: add this part of code ->
BEFORE this line :
i write it here so everyone use :
YOU can use as :
if anyone has best solution , answer the question pls :)