Download the PHP package jjgrainger/query without Composer
On this page you can find all versions of the php package jjgrainger/query. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jjgrainger/query
More information about jjgrainger/query
Files in jjgrainger/query
Informations about the package query
WordPress Query Builder v0.2.0
A fluent interface for creating WordPress Queries
Requirements
Installation
Usage
The Query class provides a fluent interface for create WP_Query in WordPress.
Creating Custom Query Classes
Custom query classes can be created by extending the Query class. Custom query classes can encapsulate default parameters which can then be expanded upon with query methods.
For example, a FeaturedPostsQuery can be created to return posts with the 'featured' taxonomy term. The default query parameters are defined within the setup() method that receives a Builder instance.
Once the query class is created it can be used through out the project in a vairety of ways.
Custom Scopes
Custom scopes can be added to the global Query using the static addScope method. One of the simplest ways to add a scope is with a closure.
Custom Scope Classes
Custom scope classes can be added to the global Query. The custom scope class will need to implement the Scope interface and contain the required apply method.
The apply method should accept the query Builder as the first argument and any optional arguments passed via the scope.
Once added to the Query class the scope will be available by the class name with the first letter lowecase.
Notes
- The library is still in active development and not intended for production use.
- Licensed under the MIT License
- Maintained under the Semantic Versioning Guide
Author
Joe Grainger