-
Notifications
You must be signed in to change notification settings - Fork 4
Template filters
Matej Simek edited this page Jan 16, 2018
·
6 revisions
Mostly based on Latte templating and filters
{$str | url}
{$str_or_array | length}
{$str | webalize}
{$str | padLeft}
{$str | padRight}
{$str | reverse}
-
{$str | truncate:100}
- shortens the$str
to fill 100 chars.
Title of $Post
.
Content of $Post
.
Excerpt of $Post
.
Permalink of $Post
.
Formats publish date of $Post
.
Converts publish date value to DateTime
object.
Returns single meta value.
Returns meta values as array.
Returns array with terms of $Post
of taxonomy by its slug
.
Returns URL to image of defined size. Works dirctly on media post_type.
Like wp_image
but works on $Post
which has a thumbnail.
Unescapes html entities, which WordPress saves to database. Then escapes with standard Latte escaping.
Replaces regular spaces with non-breaking UTF-8 characters.
Formats number to nice format, with optional decimal numbers.
Formats number, appends ,-
when no decimals and appends Kč
.
Lets add WPML Strings translate filter
// in functions.php
MangoPressTemplatingFilterSet::$set['translate'] = function($string, $domain = 'theme') {
return __($string, $domain);
};
// in template:
{='my string to translate'|translate}
// also available through macro
{_'my string to translate'}