• Resolved Sharron Denice

    (@sharrondenice)


    I am using your plugin and I would like to include HTML in my attribute values, is this possible? If not, can the plugin be hooked into to stop it from stripping html values? Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author isabel104

    (@isabel104)

    This plugin doesn’t handle the saving of the attributes, it only shows them. WooCommerce strips the HTML, but there is a work around. You can use HTML Character Entities to get some HTML to show up in the value of your attributes.

    For example, to add an HTML link, use this (change “YOUR LINK TEXT” to your own):

    <xmp><a href="#">YOUR LINK TEXT</a></xmp>

    Add bold text like this:

    <xmp><strong>BOLD TEXT</strong></xmp>

    Add an image like this (edit YOUR_IMAGE_URL.png):

    <xmp><img src="https://YOUR_IMAGE_URL.png" alt="" /></xmp>

    Important note: If you later edit this product, the HTML will be reverted back to regular HTML and then when you click “Update” to update the product, the HTML will be stripped. So the workaround to this is, if you ever have to edit this product later, go through the attribute values and replace every < with <xmp><</xmp>, and replace every > with <xmp>></xmp>

    • This reply was modified 8 years, 2 months ago by isabel104.
    • This reply was modified 8 years, 2 months ago by isabel104. Reason: Trying to display HTML character entities without parsing
    • This reply was modified 8 years, 2 months ago by isabel104.
    Plugin Author isabel104

    (@isabel104)

    *Fix:
    Please disregard all of the <xmp> tags above. I was not to display the HTML Character Entities above, but basically, you can type your HTML in the attribute value field, but replace every < with its HTML character entity, which is the & symbol followed by lt;. Also replace every > with its HTML character entity, which which is the & symbol followed by gt;.

    Thread Starter Sharron Denice

    (@sharrondenice)

    Worked like a charm!! Thanks so very much!

    TWIR

    (@mtgarmorydotcom)

    Sorry for the old bump, but is there a way to just woocommerce from stripping the html. Earlier versions of woocommerce seemed to be fine with it.

    @mtgarmorydotcom — yes, but it’s very difficult. There are no actions/hooks provided by woo-commerce. You need to find a way to cleanly hook into wp_clean yourself and stop it from doing it’s thing to *just* the attributes. Good luck!

    TWIR

    (@mtgarmorydotcom)

    So I got it to work on the front end. My problem now is with the back end. Looks like woocommerce will not allow attributes with html in them. Any clue where that might be located?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘HTML Attribute Values’ is closed to new replies.