Skip to content

Add support for nested meta queries#46

Merged
johnbillion merged 10 commits intotrunkfrom
45-nested-meta-queries
Jan 27, 2026
Merged

Add support for nested meta queries#46
johnbillion merged 10 commits intotrunkfrom
45-nested-meta-queries

Conversation

@johnbillion
Copy link
Owner

Fixes #45

@johnbillion johnbillion added this to the 2.3.0 milestone Jun 24, 2025
@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for nested meta, tax, and date queries by allowing Query objects to contain other Query objects in addition to Clause objects. This mirrors WordPress core's native nested query functionality.

Key changes:

  • Added addQuery() methods and $queries properties to all three query types (MetaQuery, TaxQuery, DateQuery)
  • Implemented isFirstOrderClause() methods to distinguish between clauses and nested queries during deserialization
  • Updated toArray() methods to serialize both clauses and nested queries with proper index handling

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/MetaQuery/Query.php Added nested query support with addQuery() method, $queries property, and isFirstOrderClause() logic
src/TaxQuery/Query.php Added nested query support with addQuery() method, $queries property, and isFirstOrderClause() logic
src/DateQuery/Query.php Added nested query support with addQuery() method, $queries property, TIME_KEYS constant, and isFirstOrderClause() logic
tests/phpunit/MetaQueryTest.php Added three new test cases for nested queries and updated test method name for clarity
tests/phpunit/TaxQueryTest.php Added three new test cases for nested queries (associative, indexed, and manual construction)
tests/phpunit/DateQueryTest.php Added three new test cases for nested queries (associative, indexed, and manual construction)
tests/WP_Query.php Added example usage of nested meta queries
README.md Added documentation example demonstrating nested query usage
composer.json Reordered test script to run phpunit before phpstan

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@johnbillion johnbillion modified the milestones: 2.3.0, 2.4.0 Jan 9, 2026
@johnbillion johnbillion marked this pull request as ready for review January 27, 2026 19:43
@johnbillion johnbillion merged commit 3dc68ad into trunk Jan 27, 2026
9 checks passed
@johnbillion johnbillion deleted the 45-nested-meta-queries branch January 27, 2026 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MetaQuery Clauses can contain subclauses

2 participants