skip to Main Content

hi everyone i want to try add
tag on the attributes item woocommerce to show any item per line .
can i help me to do that?
here is my product-attributes.php file code

<table class="woocommerce-product-attributes shop_attributes">
<?php foreach ( $product_attributes as $product_attribute_key => $product_attribute ) : ?>
    <tr class="woocommerce-product-attributes-item woocommerce-product-attributes-item--<?php echo esc_attr( $product_attribute_key ); ?>">
        <th class="woocommerce-product-attributes-item__label"><?php echo wp_kses_post( $product_attribute['label'] ); ?></th>
        <td class="woocommerce-product-attributes-item__value"><?php echo wp_kses_post( $product_attribute['value'] ); ?></td>
    </tr>
<?php endforeach; ?>

2

Answers


  1. you can try below code for example:

    <table class="woocommerce-product-attributes shop_attributes">
    <?php foreach ( $product_attributes as $product_attribute_key => $product_attribute ) : ?>
        <tr class="woocommerce-product-attributes-item woocommerce-product-attributes-item--<?php echo esc_attr( $product_attribute_key ); ?>">
            <th class="woocommerce-product-attributes-item__label"><?php echo wp_kses_post( $product_attribute['label'] ); ?></th>
            <td class="woocommerce-product-attributes-item__value"><?php echo str_replace(',','<br>',wp_kses_post( $product_attribute['value'] )); ?></td>
        </tr>
    <?php endforeach; ?>
    

    I didn’t check on a real project. let me know if it works or not.

    Login or Signup to reply.
  2. Please try following code and check if it’s working.

    <table class="woocommerce-product-attributes shop_attributes">
    <?php foreach ( $product_attributes as $product_attribute_key => $product_attribute ) : ?>
    <tr class="woocommerce-product-attributes-item woocommerce-product-attributes-item--<?php echo esc_attr( $product_attribute_key ); ?>">
        <th class="woocommerce-product-attributes-item__label"><?php echo wp_kses_post( $product_attribute['label'] ); ?></th>
        <td class="woocommerce-product-attributes-item__value"><?php echo wp_kses_post( $product_attribute['value'] ).'<br>'; ?></td>
    </tr>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search