Filters
Filters transform data in expressions. Apply them using the pipe (|) operator.
Basic Usage
{{ value|filter }}
{{ value|filter(argument) }}
{{ value|filter(arg1, arg2) }}
{{ value|filter1|filter2|filter3 }}
Available Filters
| Category | Filters |
|---|---|
| String | upper, lower, capitalize, title, trim, truncate, excerpt, excerpt_chars, striptags, nl2br, spaceless, pretags, replace, split, slug, sanitize, format, url_encode, relative |
| Number | number_format, number_i18n, abs, round |
| Date | date, date_i18n, date_modify, time_ago |
| Array | first, last, join, list, length, keys, values, slice, batch, column, merge, reverse, shuffle, sort, filter, map, reduce, find, array, wp_list_filter |
| WordPress | wpautop, wptexturize, shortcodes, stripshortcodes, antispambot |
| Utility | default, json_encode |
| Intl | country_name, currency_name, currency_symbol, language_name, locale_name, timezone_name, format_currency, format_number, format_date, format_time, format_datetime |
Quick Examples
String
{{ post.title|upper }}
{{ post.title|slug }}
{{ post.excerpt|truncate(100) }}
{{ post.content|striptags|excerpt(25) }}
Number
{{ price|number_format(2) }}
{{ rating|round(1) }}
Date
{{ post.date|date('F j, Y') }}
{{ post.date|time_ago }}
Array
{{ categories|join(', ') }}
{{ posts|filter(p => p.featured)|slice(0, 3) }}
{{ items|first }}
WordPress
{{ post.content|wpautop }}
{{ content|stripshortcodes }}
Utility
{{ value|default('fallback') }}
{{ data|json_encode }}
Intl
{{ price|format_currency('USD') }}
{{ post.date|format_date('long') }}
{{ 'US'|country_name }}
Chaining Filters
Apply multiple filters in sequence:
{{ post.title|lower|slug }}
{{ post.content|striptags|truncate(150)|trim }}
{{ post.date|date_modify('+1 day')|date('F j, Y') }}