Query
Build the arguments of WP_Query and the other WordPress query classes with a fluent, typed API in Pollora, with pollora/query.
pollora/query builds the arguments of the WordPress query classes (WP_Query, WP_Term_Query, WP_User_Query, WP_Comment_Query, WP_Site_Query, WP_Network_Query) with chained, type-hinted methods instead of nested arrays. In a Pollora project it is already installed: PostQuery is available as the Pollora\Support\Facades\PostQuery facade.
use Pollora\Support\Facades\PostQuery;
$query = PostQuery::select() ->postType('post') ->postStatus('publish') ->tagSlugIn(['laravel', 'wordpress']) ->latest() ->take(5) ->get(); // WP_QueryThe package documents every method, with a page per query class, in its docs/ folder. This page only lists what matters when you build on it from a Pollora project.
Tag arguments take slugs
Section titled “Tag arguments take slugs”tagSlugAnd() (posts that have all the tags) and tagSlugIn() (posts that have any of them) take slugs, as an array<string>, not term IDs. They write tag_slug__and and tag_slug__in. For IDs, use the tagIn() / tagAnd() family.
PostQuery::select()->tagSlugAnd(['php', 'wordpress'])->get();Extending a query class
Section titled “Extending a query class”metaQuery(), dateQuery() and taxQuery() share one protected method, mergeSubQuery(), which merges the sub-query built by the callback into the current one and returns the merged query. It replaces addSubQuery(): a subclass that called or overrode addSubQuery() must use mergeSubQuery() instead.
protected function mergeSubQuery(string $type, ?array $current, callable|SubQueryAbstract $callback): array$type is meta, tax or date. Nothing changes for code that only uses the public builders.