timber
timber copied to clipboard
found_post with Timber:get_posts();
How can I get the number of post found within a get_posts query?
$args = array(
'post_type' => 'news',
'tag_id' => $search_tag->ID,
'orderby' => 'rand'
);
$context['posts'] = Timber::get_posts($args);
//not working
$count_number = $args->found_posts;
$count_number = $context['posts']->found_posts;
Got it working:
$posts = Timber::get_posts($args);
$context['posts'] = $posts;
$posts_number = count($posts);