Rareloop\Lumberjack\Post
class. To start a query, use the builder()
method.Rareloop\Lumberjack\ScopedQueryBuilder
. This class does a couple of important things:WP_Post
objects.Employee
, when you query employees you will always get Employee
objects back as results. Lets see what this looks like:Employee
class. This is extremely powerful as you now have access to all the behaviours that come with employees, as defined in your post type class. In this case, you may have a photoUrl()
method on an Employee
that knows (encapsulates) how to get the correct size image from the featured image:photoUrl()
method:scope
, and must follow with the name of the method you want available to the builder. The method should also be defined in CamelCase
. For example:scopeFoo()
will allow you to call foo()
on a query.scopeFooBar()
will allow you to call fooBar()
on a query.getParameters
and get
.array
$postType
string
| array
post_type
in WP_Query
.$ids
array
post__in
argument in WP_Query
.$ids
array
post__not_in
argument in WP_Query
.$statuses
array
publish
or draft
$status
string
publish
or draft
$status
string
publish
or draft
post_status
argument in WP_Query
.$key
string
$value
string
$compare
string
=
$type
string
| null
null
. Pass in a value here to define the custom field type. e.g. numeric
.meta_query
arguments on WP_Query
.meta_query
takes an array of meta query arguments arrays (it takes an array of arrays) $relation
string
and
& or
relation
field for your meta queries, for WP_Query
.'relation' => 'or'
to the meta query.$limit
int
posts_per_page
argument in WP_Query
.$offset
int
offset
argument in WP_Query
.$orderBy
string
$order
string
orderby
and order
arguments in WP_Query
.$metaKey
string
$order
string
$type
string
orderby
argument for WP_Query
to meta_value
when ordering strings, and meta_value_num
when ordering numbers.$postClass
string
WP_Query
, you get an array of WP_Post
objects back. The query builder will instead return an array of Rareloop\Lumberjack\Post
objects back.Collection
of post objects.null
if there are no results.QueryBuilder
class can be extended with custom functionality at runtime (the class is "macroable"). The following example adds a search
method to the QueryBuilder
class that can be used to filter results based on a keyword search: