I'm using Timber in my wordpress theme. I created route for my /blog page which should contain posts list.
Routes::map('blog', function($params) {
Routes::load('loop.php', $params, false, 200);
});
In my loop.php
file I have this code
$context = Timber::get_context();
$args = ['posts_per_page' => 5, 'post_type' => 'post'];
$context['post'] = Timber::get_posts( $args );
$post = new TimberPost();
$context['post'] = $post;
Timber::render( 'loop/post-loop.twig', $context );
next in post-loop.twig
{% if posts %}
{% for post in posts %}
{{ post.title }}
{% endfor %}
{% else %}
<p>No matching posts</p>
{% endif %}
And now, {{post.title}}
don't display actual post title but whole page title which is "blog". Even if there's no posts loop print data. My question is what is wrong with my code and how can I make page which contain list of my posts. But in proper way. Thanks for any help.