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()
: querieswp_postmeta
comment()
: querieswp_commentmeta
user()
: querieswp_usermeta
term()
: querieswp_termmeta
blog()
: querieswp_blogmeta
site()
: querieswp_sitemeta
These are used internally by props()
and should not be called directly.