Skip to main content

Term

Term class represents a WordPress taxonomy term with associated taxonomy, metadata, and utility methods.


Description​

  • Loads and holds term data, taxonomy name, and taxonomy object.
  • Fetches child terms using QueryUtil.
  • Supports dynamic prop merging via .withProps().
  • Automatically sets metadata context for term.

Initializes the term with optional props and taxonomy name. Also sets Meta context with the termId.


Properties​

taxonomyName​

taxonomyName: types.TaxonomyName | undefined;

Returns the name of the taxonomy, if available.

taxonomy​

taxonomy: Taxonomy | undefined;

Returns the loaded Taxonomy instance, if initialized.

props​

props: Props | undefined;

Merged term, taxonomy, and relationship data from the WordPress database.


Methods​

children​

children(): Promise<types.validating.TermsResult | undefined>

Fetches child terms using the current term as the parent.

setTaxonomy​

setTaxonomy(taxonomy: Taxonomy): void

Sets the taxonomy object and updates the internal taxonomy name.

withProps​

withProps(props: Partial<Props>): this

Merges and overrides the existing props with the provided values.


Lifecycle​

init (decorated with @asyncInit)​

private init(): Promise<void>

Initializes term data and attempts to load the taxonomy if not already set.