I would like to render this loop in Timber. Can I have some help please ?
$query = get_posts(array('post_type' => 'lexique','posts_per_page' => -1));
$by_letter = array();
while( $query->have_posts() ) { $query->the_post();
global $post;
$letter = substr($post->post_name, 0, 1);
if ( ! isset($by_letter[$letter]) ) $by_letter[$letter] = array();
$by_letter[$letter][] = $post;
}
wp_reset_postdata();
So attach this loop with timber
$context = Timber::get_context();
Timber::render('lexique.twig', $context);
But I don't have any idea to do this.