Skip to content
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.

WP filters

{$Post | wp_title}

Title of $Post.

{$Post | wp_content}

Content of $Post.

{$Post | wp_excerpt}

Excerpt of $Post.

{$Post | wp_permalink}

Permalink of $Post.

{$Post | wp_date:'j.n.Y'}

Formats publish date of $Post.

{$Post | wp_DateTime}

Converts publish date value to DateTime object.

{$Post | wp_meta:'meta_name'}

Returns single meta value.

{$Post | wp_meta_list:'meta_name'}

Returns meta values as array.

{$Post | wp_terms:'taxonomy_slug'}

Returns array with terms of $Post of taxonomy by its slug.

{$Image | wp_image:'xl'}

Returns URL to image of defined size. Works dirctly on media post_type.

{$Post | wp_thumbnail:'xl'}

Like wp_image but works on $Post which has a thumbnail.

{$Post | wp_esc}

Unescapes html entities, which WordPress saves to database. Then escapes with standard Latte escaping.

{$str | nbsp}

Replaces regular spaces with non-breaking UTF-8 characters.

{$number | number:2}

Formats number to nice format, with optional decimal numbers.

{$str | czk:2}

Formats number, appends ,- when no decimals and appends .

Add your custom filters

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'}