Using HTML in custom fields – Textpattern

One of our customers wanted their course titles to be displayed with a <span> around a keyword in order to highlight it.

Our initial thought was ‘simple!’ we’ll just add the title with the required span to the Article as a custom field, in this instance called “widgettitle” and output it like this:

<txp:custom_field name=”widgettitle” />

Unfortunately this just produces ‘REAL <span>PRESENTATIONS</span>’ which wasn’t the desired effect!

Solving it is simple (once you’ve searched a bit!) all you need to do is add escape=”” to the TXP tag like this:

<txp:custom_field name=”widgettitle” escape=”” />

Now your ‘code’ in the custom won’t be parsed into HTML

Yay!

Leave a Reply

Your email address will not be published. Required fields are marked *