Timber Logo

You are reading the documentation for Timber v1.x. Switch to the documentation for Timber v2.x.

Timber\PostQuery

A PostQuery allows a user to query for a Collection of WordPress Posts. PostCollections are used directly in Twig templates to iterate through and retrieve meta information about the collection of posts

Overview #

Properties #

NameTypeDescription
found_postsintThe amount of posts found in the query.

Class Methods #

__construct #

__construct( bool/mixed $query=false, string $post_class="\Timber\Post" )

returns: void

NameTypeDescription
$querybool/mixed
$post_classstring

pagination #

pagination( array $prefs=array() )

returns: \Timber\Timber\Pagination object

Set pagination for the collection. Optionally could be used to get pagination with custom preferences.

NameTypeDescription
$prefsarray

get_query #

get_query( )

returns: mixed the query the user orignally passed to the pagination object


This class extends \Timber\PostCollection

This class implements \IteratorAggregate, \Traversable, \ArrayAccess, \Serializable, \Countable