function testPostCount() { $posts = $this->factory->post->create_many(8); $posts = TimberPostGetter::query_posts('post_type=post'); $this->assertEquals(8, $posts->post_count()); $this->assertEquals(8, count($posts)); }
function testTheLoop() { for ($i = 1; $i < 3; $i++) { $this->factory->post->create(array('post_title' => 'TestPost' . $i)); } $results = Timber::compile('assets/iterator-test.twig', array('posts' => TimberPostGetter::query_posts('post_type=post'))); $results = trim($results); $this->assertStringStartsWith('TestPost2', $results); $this->assertStringEndsWith('TestPost1', $results); }
/** * Get posts from WP_Query. * * @param array $query * @param string $PostClass * @return array * @deprecated since 0.20.0 */ static function get_posts_from_wp_query($query = array(), $PostClass = 'TimberPost') { return TimberPostGetter::query_posts($query, $PostClass); }
/** * Query posts. * * @param mixed $query * @param string $PostClass * @return array|bool|null */ public static function query_posts($query = false, $PostClass = 'TimberPost') { return TimberPostGetter::query_posts($query, $PostClass); }