Skip to main content

WordPress Functions

These functions retrieve WordPress objects so you can chain property access. All return provider objects except get_taxonomy, which returns the WordPress taxonomy object as is.

FunctionReturnsDescriptionExample
get_postPostSingle post by ID{{ get_post(42).title }}
get_postsCollectionPosts by query args{{ get_posts({post_type: 'page'}) }}
get_termTermSingle term by ID{{ get_term(5).name }}
get_termsCollectionTerms by query args{{ get_terms({taxonomy: 'category'}) }}
get_userUserSingle user by ID{{ get_user(1).display_name }}
get_usersCollectionUsers by query args (authors, or members of public roles){{ get_users({number: 10}) }}
get_imageImageSingle image by ID{{ get_image(100).src('medium') }}
get_taxonomyTaxonomyTaxonomy object by slug — for accessing labels{{ get_taxonomy('category').label }}

Single Object Functions​

Retrieve a specific object by ID and access any of its fields:

{{ get_post(42).title }}
{{ get_post(42).date('F j, Y') }}
{{ get_term(3).name }}
{{ get_term(3).link }}
{{ get_user(1).display_name }}
{{ get_user(1).avatar({size: 96}) }}
{{ get_image(post.thumbnail_id).src('medium') }}

get_post finds a post of any viewable type, published or an attachment, and nothing else: a draft or a private post gives nothing.

Taxonomy Lookup​

get_taxonomy(slug) returns the WordPress taxonomy object — useful when you have a taxonomy slug (e.g. from term.taxonomy) and need the human-readable label or other taxonomy info:

{{ get_taxonomy('category').label }}                    <!-- 'Categories' -->
{{ get_taxonomy('category').labels.singular_name }} <!-- 'Category' -->
{{ get_taxonomy(term.taxonomy).label }} <!-- Label for the current term's taxonomy -->
{{ get_taxonomy('product_cat').hierarchical }}

Collection Functions​

Retrieve multiple objects using query arguments. Returns a collection to iterate in a Loop or to count; printed as is, it shows nothing:

{% for page in get_posts({post_type: 'page', posts_per_page: 5}) %}
{% for term in get_terms({taxonomy: 'category', hide_empty: true}) %}
{{ get_users({number: 50})|length }}

Default limits when not specified:

  • get_posts — 10 posts (posts_per_page: 10)
  • get_terms — 10 terms (number: 10)
  • get_users — 10 users (number: 10)

get_posts also defaults post_type to post (or, with a taxonomy filter, to the types of that taxonomy, as WordPress does) and skips counting the total: found_posts stays 0 and there's no pagination unless you pass no_found_rows: false. For a total or pagination before a loop, use a Variable block with the Query source.

Security

WordPress functions enforce security: viewable post types only when given ('any' is WordPress's), permission checks on non-public statuses, MIME type validation for images, and private data (readable users only, no filter or sort on a private field).