queryPosts( )


Creates a query to retrieve a list of posts.

The queryPosts() function builds a query to retrieve a list of up to 100 posts, and returns a PostsQueryBuilder object.

The returned object contains the query definition which is typically used to run the query using the find() function.

You can refine the query by chaining PostsQueryBuilder functions onto the query. PostsQueryBuilder functions enable you to sort, filter, and control the results that queryPosts() returns.

queryPosts() runs with these PostsQueryBuilder defaults that can be overridden:

Note that the default limit is '50', but the max limit is '100'.

To learn how to query posts, refer to the table below.

The following PostsQueryBuilder functions are supported for the queryPosts() function. For a full description of the Posts object, see the object returned for the items property in PostsQueryResult.

PROPERTYSUPPORTED FILTERS & SORTING
_ideq(),ne(),hasSome(),ascending(),descending()
titleeq(),ne(),startsWith(),hasSome(),exists(),in(),ascending(),descending()
firstPublishedDateeq(),ne(),lt(),le(),gt(),ge(),in(),ascending(),descending()
lastPublishedDateeq(),ne(),lt(),le(),gt(),ge(),in(),ascending(),descending()
slugeq(),ne(),hasSome(),ascending(),descending()
featuredeq(),ne(),ascending(),descending()
pinnedeq(),ne(),ascending(),descending()
categoryIdshasSome(),hasAll()
coverMedia.enabledeq(),ne()
memberIdeq(),ne(),hasSome()
hashtagshasSome(),hasAll()
commentingEnabledeq(),ne(),ascending(),descending()
minutesToReadeq(),ne(),lt(),le(),gt(),ge(),in()
tagIdshasSome(),hasAll()
pricingPlanIdshasSome(),hasAll()
translationIdeq(),ne(),exists(),in()
languageeq(),ne(),hasSome(),exists(),in()
metrics.commentseq(),ne(),lt(),le(),gt(),ge(),in(),ascending(),descending()
metrics.likeseq(),ne(),lt(),le(),gt(),ge(),in(),ascending(),descending()
metrics.viewseq(),ne(),lt(),le(),gt(),ge(),in(),ascending(),descending()
Permissions
Read Blog
Manage Blog
Read Draft Blog Posts
Learn more about app permissions.
Method Declaration
Copy
Method Parameters
optionsQueryPostsOptions

Options specifying which fields to return.

Returns
Return Type:PostsQueryBuilder
Was this helpful?
Yes
No