I'm using Timber for my Wordpress theme and for some time now I've noticed that Timber does not show the content of new pages created.
Here is an example of my structure:
I have a work.php page that contains the following context:
$context = Timber::get_context();
$args = array(
// Get post type project
'post_type' => 'project',
// Get all posts
'posts_per_page' => -1,
// Order by post date
'orderby' => array(
'date' => 'DESC'
)
);
$context['post'] = new TimberPost();
$context['works'] = Timber::get_posts( $args );
Timber::render( 'page-work.twig', $context );
Then I have a "page-work.twig" page retrieves an include "inc-work.twig"
{% extends "base.twig" %}
{% block content %}
{% include 'inc-work.twig' %}
{% endblock %}
Here is the inc-work.twig include
<section class="l-homegrid lazy-scroll">
{% for post in works %}
{% if post.thumbnail %}
<a href="{{post.link}}" class="l-basicgrid-work work">
<article>
<figure>
<img data-src="{{post.get_thumbnail.src('full')|resize(800, 533)}}" alt="project {{post.title}}" class="lazy">
</figure>
<figcaption>
<h2>{{ post.title }}</h2>
</figcaption>
</article>
</a>
{% endif %}
{% endfor %}
</section>
I feel that my code is correct. However, the Custom Content Type "Project" is not displayed. It's strange, because I use the structure without any problem for other pages of the same site ...
Any ideas?
Thank you!
workorproject? Are you sure that work.php is displayed? And did you realize that you’re renderingpage-graphic.twig, but you listpage-work.twigas the Twig view? - Gchtr{% for post in works %}in your Twig file, but I don’t see where you addworksto your context. You addgraphics, though. Might this be the problem? - Gchtr$context['post'] = new TimberPost(); $context['works'] = Timber::get_posts( $args ); Timber::render( 'page-work.twig', $context );But anyway, nothing it is rendered... - filnug{{ dump(post) }}right after{% for post in works %}? - Gchtr