Inheritance: extends ArrayObject
Exemplo n.º 1
0
 public function get_posts($return_collection = false)
 {
     if (isset($this->_query->posts)) {
         $posts = new PostCollection($this->_query->posts, $this->_posts_class);
         return $return_collection ? $posts : $posts->get_posts();
     }
 }
Exemplo n.º 2
0
 /**
  * @param mixed   	$query
  * @param string 	$post_class
  */
 public function __construct($query = false, $post_class = '\\Timber\\Post')
 {
     $this->userQuery = $query;
     $this->queryIterator = PostGetter::query_posts($query, $post_class);
     $posts = $this->queryIterator->get_posts();
     parent::__construct($posts, $post_class);
 }
Exemplo n.º 3
0
 /**
  * @param mixed $query
  * @param string|array $PostClass
  * @return array|bool|null
  */
 public static function get_post($query = false, $PostClass = '\\Timber\\Post')
 {
     // if a post id is passed, grab the post directly
     if (is_numeric($query)) {
         $post_type = get_post_type($query);
         $PostClass = PostGetter::get_post_class($post_type, $PostClass);
         $post = new $PostClass($query);
         // get the latest revision if we're dealing with a preview
         $posts = PostCollection::maybe_set_preview(array($post));
         if ($post = reset($posts)) {
             return $post;
         }
     }
     $posts = self::get_posts($query, $PostClass);
     if ($post = reset($posts)) {
         return $post;
     }
 }