Inicio - Documentación - POM Theme - 08 Templates - Single templates

Single templates

A single template renders the body for the current post or POM custom post type item. Its merge tags use that item's fields, media and metadata.

Conditions

Conditional blocks inspect one custom field:

{{if meta="event_status" value="confirmed"}}
    <p>Confirmed</p>
{{else}}
    <p>Provisional</p>
{{/if}}
value Match
An exact value The saved field equals that value
empty The field has no value
not_empty The field has a value

Conditions use the same syntax and comparisons as feed templates. They can contain HTML, other merge tags, shortcodes, nested conditions and an optional {{else}} branch. Only the selected branch is rendered. Close every condition with its own {{/if}}.

{{if meta="event_status" value="confirmed"}}
    {{if meta="venue" value="not_empty"}}
        <p>{{meta name="venue" only_content="true"}}</p>
    {{else}}
        <p>Venue to be announced.</p>
    {{/if}}
{{else}}
    <p>Confirmation pending.</p>
{{/if}}

Exact comparisons are case-sensitive. As in feed templates, empty also matches a missing field, zero (0 or "0"), false and an empty array; not_empty matches values that are not empty. Check the result on items with populated and missing fields before publishing.

Main post fields

Merge tag Attributes Result
{{post_id}} None Current post ID
{{title}} None Title
{{content}} fallback_message Full content or the supplied fallback
{{excerpt}} limit Plain excerpt, shortened to the character limit
{{permalink}} None Permalink
{{date}} None Publish date
{{modified}} None Modified date
{{author_name}} None Author display name
{{posts_nav}} None Previous/next post navigation

Examples:

<h1>{{title}}</h1>
<p>{{excerpt limit="150"}}</p>
<div class="entry-content">
    {{content fallback_message=%%No description is available.%%}}
</div>
{{posts_nav}}

Content and fallback shortcodes are processed. A password-protected post displays its password form instead of the fallback.

Featured image

Return complete image HTML:

{{featured_image image_size="large"}}

Return only its URL:

<div class="hero" style="background-image:url('{{featured_image_url image_size="full"}}')"></div>

image_size accepts a registered WordPress image size. These tags are empty when no featured image can be resolved.

Custom-field image

{{image_from_meta name="speaker_portrait"}}

name is the custom-field key containing the image value. The tag returns image HTML when the value can be resolved.

Known attachment dimensions are included automatically as numeric width and height attributes, including dimensions recovered from local SVG files. Set either dimension to a positive integer in pixels to control the image size; omit the other or use auto to preserve its proportions:

{{image_from_meta name="speaker_portrait" width="160" height="auto"}}
{{image_from_meta name="square_icon" width="40" height="40"}}

With both dimensions omitted or set to auto, the source dimensions are used. An SVG with only a viewBox needs at least one numeric dimension to produce a complete numeric pair. Unresolvable dimensions are omitted, and invalid values or CSS units such as 40px are ignored. The generated HTML never contains width="auto" or height="auto". CSS can override the display dimensions; use height: auto when changing an image's width proportionally.

Feed and single templates share the same custom-field image dimension rules and SVG requirements.

Gallery

{{gallery
    meta_name="event_gallery"
    style="masonry"
    image_size="large"
    lightbox_click="yes"
}}
Attribute Purpose
meta_name Required gallery field key
style Gallery presentation, including grid, masonry, carrousel, carousel_2, full_screen or images_only
image_size Registered WordPress image size
lightbox_click Use yes to open images in the supported lightbox presentation

images_only returns a simple series of images without the gallery presentation wrapper.

Custom metadata

{{meta name="venue"}}
{{meta name="start_date" type="date" only_content="true"}}
{{meta name="doors_open" type="time" prepend=%%Doors: %% icon="feather/clock"}}
Attribute Purpose
name Required custom-field key
type Format the value as date, datetime or time
only_content Use true to omit the default metadata wrapper
prepend Text before the value
append Text after the value
icon Icon shown with the wrapped form
translatable Marks supported labels for translation

When only_content="true" is omitted, POM adds a metadata wrapper with classes based on the field key.

Icons and translated strings

{{icon family="feather" name="map-pin"}}
{{translatable_string text=%%Location%%}}

Use %%...%% for translated labels containing spaces or punctuation. See Format merge-tag attributes for nested labels.

Complete example

<article class="profile">
    <header class="profile-header">
        {{featured_image image_size="medium_large"}}
        <div>
            <h1>{{title}}</h1>
            {{if meta="role" value="not_empty"}}
                <p>{{meta name="role" only_content="true"}}</p>
            {{/if}}
        </div>
    </header>

    <div class="profile-content">{{content}}</div>

    {{if meta="photo_gallery" value="not_empty"}}
        {{gallery meta_name="photo_gallery" style="grid" image_size="medium" lightbox_click="yes"}}
    {{/if}}

    {{posts_nav}}
</article>

Related guides