• Resolved 2CAN

    (@2can)


    Hi, i would to modify the single product page in my shop site.
    I have to remove links from attribute list in the Additional Information Tab.

    I found this html is called in this page: /woocommerce/templates/single-product/product-attributes.php

    In this part of code:
    <td class="woocommerce-product-attributes-item__value"><?php echo wp_kses_post( $product_attribute['value'] ); ?></td>

    Do you know if exist another argument instead “value” for example “slug” or “name”?
    If not, how can modify the call to show only value without link?

    Thank’s

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    Thank you for doing the preliminary research to identify the correct template. The answer is at the top of the template file you referenced.

    This template can be overridden by copying it to yourtheme/woocommerce/single-product/product-attributes.php.

    You need to override the template. Copy it as directed, but do make note of the “HOWEVER” clause below that phrase in the file. Once copied over, remove the offending line from the theme version of the file.

    Thread Starter 2CAN

    (@2can)

    hi,
    i know how to override the page, i already use a child theme.
    what i need is how to call only the attribute name, because
    wp_kses_post( $product_attribute['value'] )

    creates html code inclusive the link

    Thank’s

    Thread Starter 2CAN

    (@2can)

    This is the solutions, solved in another forum by user itzmekhokan

    _____________________

    Add the follows code snippet in your active theme’s functions.php –

    function filter_woocommerce_attribute_value( $value ) { 
        return preg_replace( '#<a.*?>([^>]*)</a>#i', '$1', $value );
    }
    
    add_filter( 'woocommerce_attribute', 'filter_woocommerce_attribute_value', 99 );
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Woocommerce Attributes Link’ is closed to new replies.