Skip to main content

Post

Access current post data. Available on single post/page views and inside Loop blocks (via the loop data alias).

All Fields

FieldArgumentsReturnsDescription
idintPost ID
titlestringPost title
slugstringPost name (URL slug)
formatstring | falsePost format slug, false when no format
excerpt{options}stringPost excerpt (chainable builder)
contentpage, len, remove_blocksstringPost content (filtered)
paged_contentstringCurrent page content (for paginated posts)
linkstringPermalink URL
pathstringURL path only
edit_linkstring | nullAdmin edit URL (null when not authorized)
dateformatstringPublish date
timeformatstringPublish time
timestampintUnix timestamp
modified_dateformatstringLast modified date
modified_timeformatstringLast modified time
modified_timestampintModified unix timestamp
authorUserPost author
modified_authorUserLast editor
thumbnailImageFeatured image
thumbnail_idint | falseFeatured image ID, false if none
categoryTermPrimary category (comparable to a string)
categoriesarrayAll categories
tagsarrayAll tags
termstaxonomy, optionsarrayTerms from taxonomy
has_termterm, taxonomyboolCheck if has term
typestringPost type slug, chainable to .labels.*
parentPost | falseParent post (false if no parent)
ancestorsarrayAncestor posts
childrenpost_typearrayChild posts
nextin_same_termPost | falseNext post (false if none)
previn_same_termPost | falsePrevious post (false if none)
commentscount, order, type, statusiterablePost comments (chainable)
comment_countintNumber of comments
can_editboolCurrent user can edit
password_requiredboolPassword protected
paginationobjectPagination data for paginated posts
galleryhtmlmixedAttached gallery
post_classclassstringCSS classes
metafield_namemixedPost meta value
raw_metafield_namemixedUnescaped meta value
has_fieldfield_nameboolCheck if field exists

Raw Database Fields

Direct read access to the underlying WP_Post columns — useful when you need the exact stored value (no filtering, no formatting):

FieldReturnsDescription
IDintPost ID (alias of id)
post_titlestringTitle (raw)
post_namestringSlug (alias of slug)
post_authorintAuthor user ID
post_typestringPost type slug
post_parentintParent post ID, 0 if none
post_statusstringpublish, draft, pending, private, etc.
post_date / post_date_gmtstringPublish date in YYYY-MM-DD HH:MM:SS
post_modified / post_modified_gmtstringModified date in YYYY-MM-DD HH:MM:SS
post_mime_typestringMIME type (mainly for attachments)
post_contentstringRaw post content (capability-gated)
post_excerptstringRaw post excerpt
comment_statusstring'open' or 'closed'
menu_orderintManual order value

Content

content

Arguments:

  • page — Page number for paginated content (default: 0 = all)
  • len — Word limit (default: -1 = no limit)
  • remove_blocks — Remove block markup (default: false)
{{ post.content }}
{{ post.content(2) }} <!-- Page 2 only -->
{{ post.content(0, 50) }} <!-- Limit to 50 words -->
{{ post.content(0, -1, true) }} <!-- Remove blocks -->

excerpt

post.excerpt is a chainable builder. You can pass an options object or chain methods to refine it — both styles work and you can mix them.

Options object:

  • words — Word count (default: 50)
  • chars — Character limit (overrides words)
  • end — Suffix text (default: '…')
  • force — Force from content even if excerpt exists (default: false)
  • strip — Strip HTML tags (default: true)
  • read_more — "Read more" link text (default: none)
  • the_content — Use full WordPress excerpt filter (default: false, slower)
{{ post.excerpt }}
{{ post.excerpt({words: 25}) }}
{{ post.excerpt({chars: 150}) }}
{{ post.excerpt({words: 30, end: '...'}) }}
{{ post.excerpt({force: true}) }}
{{ post.excerpt({read_more: 'Continue reading'}) }}

Chained methods:

{{ post.excerpt.length(25) }}                          <!-- 25 words -->
{{ post.excerpt.chars(150) }} <!-- 150 chars -->
{{ post.excerpt.length(30).end('...') }}
{{ post.excerpt.force(true) }}
{{ post.excerpt.read_more('Continue reading') }}
{{ post.excerpt.strip(true).length(20) }}

Dates

format: PHP date format string (default: WordPress setting)

{{ post.date }}                               <!-- Uses WP date format -->
{{ post.date('F j, Y') }} <!-- January 15, 2024 -->
{{ post.time }} <!-- Uses WP time format -->
{{ post.time('g:i a') }} <!-- 2:30 pm -->
{{ post.timestamp }} <!-- 1705330245 -->
{{ post.modified_date('Y-m-d') }}

Author

The author field returns a User object with all user fields.

{{ post.author.name }}
{{ post.author.avatar }}
{{ post.modified_author.name }}
Shorthand

post.author is also available as the root author variable. See User & Author for details.

The thumbnail field returns an Image object.

{{ post.thumbnail.src }}
{{ post.thumbnail.src('medium') }}
{{ post.thumbnail.alt }}
{{ post.thumbnail.width }}
{{ post.thumbnail_id }} <!-- false when no thumbnail -->

Post Type

post.type returns the post type slug — you can compare it directly to a string and chain into the post type object's labels:

{{ post.type }}                                <!-- 'post' or 'page' or CPT slug -->
{{ post.type.labels.singular_name }} <!-- 'Post' / 'Page' / etc. -->

Taxonomies

category / categories / tags / terms

Term references stringify to the term name and support direct comparison — no need to access .name explicitly:

{{ post.category }}                           <!-- 'News' -->
{{ post.category.link }}
{{ post.category.slug }}

terms

Arguments:

  • taxonomy — Taxonomy name, array of names, or 'all' (default: 'all')
  • options{merge: true} to combine or {merge: false} to group by taxonomy
{{ post.terms('genre') }}
{{ post.terms(['category', 'post_tag']) }}
{{ post.terms('all') }}
{{ post.terms('category', {merge: false}) }}

has_term

Arguments:

  • term — Term name, slug, or ID
  • taxonomy — Taxonomy name (default: 'all')
{{ post.has_term('news') }}
{{ post.has_term('news', 'category') }}
{{ post.has_term(5, 'category') }}

Hierarchy

children

Arguments:

  • post_type — Post type to get, 'parent' for same type, or query array (default: 'any')
{{ post.children }}
{{ post.children('page') }}
{{ post.children('parent') }}
{{ post.children({post_type: 'page', orderby: 'title'}) }}

parent / next / prev

These return false (not null) when there's no adjacent post — match against the value before chaining:

{{ post.parent.title }}
{{ post.next.title }}
{{ post.next(true) }} <!-- Same category -->
{{ post.next('genre') }} <!-- Same genre term -->
{{ post.prev.title }}
{{ post.prev(true) }}

Comments

post.comments returns an iterable, chainable comment thread.

Arguments:

  • count — Number of comments (default: all)
  • order'ASC', 'DESC', or 'wp' for WP setting (default: 'wp')
  • type — Comment type (default: 'comment')
  • status — Comment status (default: 'approve')
{{ post.comments }}
{{ post.comments(5) }} <!-- Latest 5 -->
{{ post.comments(10, 'DESC') }} <!-- Latest 10, newest first -->
{{ post.comments.order('DESC') }} <!-- Chainable order -->
{{ post.comments.orderby('comment_date') }} <!-- Chainable orderby -->
{{ post.comments.order('DESC').orderby('comment_date') }}
{{ post.comment_count }}
PII protection

Comment author email, IP address, and user agent are stripped before iteration — they're never available in templates. Only public-facing comment data (author name, content, date, etc.) is exposed.

Other Fields

Arguments:

  • html — Return HTML galleries (default: true)
{{ post.gallery }}
{{ post.gallery(false) }} <!-- Return data only -->

post_class

Arguments:

  • class — Extra class(es) to add
{{ post.post_class }}
{{ post.post_class('custom-class') }}

Custom Fields (Meta)

{{ post.meta('event_date') }}
{{ post.meta('address').city }}
{{ post.has_field('custom_field') }}
Plugin integration

meta('key') integrates with ACF, MetaBox, JetEngine, and Pods — the plugin filter resolves the value through those frameworks when active. Private meta keys (starting with _) are blocked for security.

Common Patterns

Post card

{{ post.title }}
{{ post.excerpt({words: 25}) }}
{{ post.date('F j, Y') }}
{{ post.author.name }}
{{ post.thumbnail.src('medium') }}

Custom field with fallback

{{ post.meta('custom_title') ?? post.title }}
{{ post.meta('custom_excerpt') ?? post.excerpt }}

Post navigation

{% if post.prev %}<a href="{{ post.prev.link }}">{{ post.prev.title }}</a>{% endif %}
{% if post.next %}<a href="{{ post.next.link }}">{{ post.next.title }}</a>{% endif %}

Taxonomy list

{{ post.categories|map(c => c.name)|join(', ') }}
{{ post.tags|map(t => t.name)|join(', ') }}
{{ post.thumbnail ? post.thumbnail.src('large') : '/default.jpg' }}
{{ post.thumbnail.alt ?: post.title }}