Skip to main content

Meta

Meta class handles loading and accessing metadata from WordPress meta tables (e.g., postmeta, usermeta, etc).


Description

  • Supports all core meta tables via MetaTable type: post, user, term, comment, blog, and site.
  • Loads metadata only when accessed (lazy-loaded).
  • Uses formatting.primitive() to parse values.
  • Compatible with QueryUtil for fetching and filtering.

Usage

const context = await Application.getContext();
const meta = context.components.get(Meta, ["post", 1]);
const props = await meta.props();

Methods

set

set(table: types.MetaTable, id: number): this

Reassigns the internal table and ID this Meta instance refers to.

setProps

setProps(props: Record<string, any>): void

Directly sets the internal _props cache.

get

get<T = any>(key: string): Promise<T | undefined>

Returns a single metadata value. If props have not been loaded, loads all metadata first.

props

props(): Promise<Record<string, any>>

Returns all meta properties for the current entity. Meta values are parsed and cached.


Internal Query Methods

These methods query specific meta tables based on the table and id:

  • post(): queries wp_postmeta
  • comment(): queries wp_commentmeta
  • user(): queries wp_usermeta
  • term(): queries wp_termmeta
  • blog(): queries wp_blogmeta
  • site(): queries wp_sitemeta

These are used internally by props() and should not be called directly.