public static function query_posts($query = false, $PostClass = '\\Timber\\Post')
{
if ($type = self::get_class_for_use_as_timber_post($query)) {
$PostClass = $type;
if (self::is_post_class_or_class_map($query)) {
$query = false;
}
}
if (is_object($query) && !is_a($query, 'WP_Query')) {
// The only object other than a query is a type of post object
$query = array($query);
}
if (is_array($query) && count($query) && isset($query[0]) && is_object($query[0])) {
// We have an array of post objects that already have data
return new PostCollection($query, $PostClass);
} else {
// We have a query (of sorts) to work with
$tqi = new QueryIterator($query, $PostClass);
return $tqi;
}
}