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
namestringPost name (alias for slug)
slugstringPost slug
statusstringPost status
formatstringPost format
excerpt{options}stringPost excerpt
contentpage, len, remove_blocksstringPost content (filtered)
paged_contentstringCurrent page content (for paginated posts)
linkstringPermalink URL
pathstringURL path only
edit_linkstringAdmin edit URL
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_idintFeatured image ID
categoryTermPrimary category
categoriesarrayAll categories
tagsarrayAll tags
termstaxonomy, optionsarrayTerms from taxonomy
has_termterm, taxonomyboolCheck if has term
typeobjectPost type object
parentPostParent post
ancestorsarrayAncestor posts
childrenpost_typearrayChild posts
nextin_same_termPostNext post
previn_same_termPostPrevious post
commentscount, order, type, statusarrayPost comments
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

Basic Fields

{{ post.id }}
{{ post.title }}
{{ post.slug }}
{{ post.status }}

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

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'}) }}
{{ post.excerpt({the_content: true}) }}

URLs

{{ post.link }}
{{ post.path }}
{{ post.edit_link }}

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

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

Taxonomies

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

next / prev

Arguments:

  • in_same_term — Stay in same taxonomy term. true, false, or taxonomy name (default: false)
{{ post.next }}
{{ post.next(true) }} <!-- Same category -->
{{ post.next('genre') }} <!-- Same genre term -->
{{ post.prev }}
{{ post.prev(true) }}

Comments

comments

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.comment_count }}

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('price') }}
{{ post.meta('event_date') }}
{{ post.meta('address').city }}
{{ post.has_field('custom_field') }}

Note: 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

{{ post.prev.title ?? '' }}
{{ post.next.title ?? '' }}

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