This documentation describes unreleased changes on the main branch.

Terms

Class.

use Saij\WpAppFramework\Query\Terms;

Conditions on the terms of a taxonomy, named by its class (#[Taxonomy]): Terms::in(Genre::class, [$jazz, $blues]). Terms are WP_Term objects or term IDs.

Methods

all()

Terms::all(string $taxonomy, array $terms, bool $includeChildren = true): Condition

Posts with all of the terms.

ParameterTypeDefaultDescription
taxonomyclass-stringrequiredTaxonomy class: a class with #[Taxonomy], Category or Tag.
termslist<WP_Term|int>requiredTerms as objects or IDs; at least one.
includeChildrenbooltrueThe child terms of the terms count as well (hierarchical taxonomies).

Returns Condition

exists()

Terms::exists(string $taxonomy): Condition

Posts with any term of the taxonomy.

ParameterTypeDefaultDescription
taxonomyclass-stringrequiredTaxonomy class: a class with #[Taxonomy], Category or Tag.

Returns Condition

in()

Terms::in(string $taxonomy, array $terms, bool $includeChildren = true): Condition

Posts with at least one of the terms; with their child terms by default, like WordPress.

ParameterTypeDefaultDescription
taxonomyclass-stringrequiredTaxonomy class: a class with #[Taxonomy], Category or Tag.
termslist<WP_Term|int>requiredTerms as objects or IDs; at least one.
includeChildrenbooltrueThe child terms of the terms count as well (hierarchical taxonomies).

Returns Condition

notExists()

Terms::notExists(string $taxonomy): Condition

Posts without a term of the taxonomy.

ParameterTypeDefaultDescription
taxonomyclass-stringrequiredTaxonomy class: a class with #[Taxonomy], Category or Tag.

Returns Condition

notIn()

Terms::notIn(string $taxonomy, array $terms, bool $includeChildren = true): Condition

Posts with none of the terms.

ParameterTypeDefaultDescription
taxonomyclass-stringrequiredTaxonomy class: a class with #[Taxonomy], Category or Tag.
termslist<WP_Term|int>requiredTerms as objects or IDs; at least one.
includeChildrenbooltrueThe child terms of the terms count as well (hierarchical taxonomies).

Returns Condition