I’m Not Using Timber Anymore – Here’s Why

In the past eight months, I have stopped using Timber in my WordPress projects.

Hold on to your pitchfork! Let me explain.

It is a great plugin that I have used for seven years. But I feel the downsides outweigh the benefits now.

What are the downsides? Let’s discuss

1. Hard to Find Developers

I’ve been working solo for the past few years. So whatever niche technology I used didn’t matter.

Now that I started working as a team, it’s clear that very few people are using Timber. And those who know how, use it in their own way. There’s no standard!

I can’t afford the time to teach them since I’m working with several freelancers on multiple projects.

It’s simply more efficient to use a pure PHP template that everyone knows how to use.

2. Hard to Integrate with Some Plugins

Try making a WooCommerce store with Timber. It’s a mess!

There are some resources to help you with integrating WooCommerce such as the official Timber docs. But you can’t say the same for other plugins.

3. We Have Built-in Alternative

WordPress version 5.5 brought us a very useful upgrade to get_template_part(). It has 3rd parameter to pass in an array to the template file.

Yes, it is similar to what Timber::render() does. This means you can create a Timber-like structure without any plugin. Here’s an example:

<?php
global $wp_query;

$args = [
  'title' => 'Welcome to my Blog',
  'posts' => $wp_query->get_posts(),
];

get_header();
get_template_part('views/posts', '', $args);
get_footer();
<main role="main">
  <h1>
    <?php echo $args['title']; ?>
  </h1>

<?php if (count($args['posts']) > 0): ?>
  <ul class="wp-block-latest-posts is-grid columns-3 alignwide">
  <?php foreach ($args['posts'] as $post): ?>
    <?php setup_postdata($post); ?>

    <li>
      <?php if (has_post_thumbnail()): ?>
        <div class="wp-block-latest-posts__featured-image">
          <a href="<?php the_permalink(); ?>">
            <?php the_post_thumbnail('medium'); ?>
          </a>
        </div>
      <?php endif; ?>

      <a href="<?php the_permalink(); ?>">
        <?php the_title(); ?>
      </a>

      <div class="wp-block-latest-posts__post-author">
        by <?php the_author(); ?>
      </div>
      <time datetime="{{ post.post_date }}">
        <?php echo get_the_date(); ?>
      </time>
      <div class="wp-block-latest-posts__post-excerpt">
        <?php the_excerpt(); ?>
      </div>
    </li>
  <?php endforeach; ?>
  </ul>

<?php else: ?>
  <h1 class="has-text-align-center">
    No Posts Found
  </h1>
<?php endif; ?>
<?php wp_reset_postdata(); ?>
</main>

Although more wordy than TWIG, we did separate the template and logic. We just need to make sure to keep out complex logic from the views file.

If you are interested to see a full-fledged theme using this concept, check out my theme called Edje:

Conclusion

Timber is a great plugin. But we can use get_template_part() for the same benefit while avoiding the learning curve and potential incompatibility.

Having a quick onboarding process for new developer or freelancer is also a blessing.

I know this post is controversial to Timber-lover out there. As a former huge advocate of Timber, I just want to share what changed my perspective toward it.

Thank you for reading. If you have any question or rebuttal, feel free to voice your opinion in the comment below

Default image
Henner Setyono
A web developer who mainly build custom theme for WordPress since 2013. Young enough to never had to deal with using Table as layout.
Leave a Reply to Phuc LeCancel Reply

3 Comments

  1. Hi everyone, Sorry that it's been more than 1 year since my last post in this blog. I have been incredibly busy the past year.

    The fact is, it took me 6-10 hours per post which is hugely time consuming. Only recently that I manage to find spare time to start writing again.

    This year, I'm aiming for at least 2 posts per month. Ideally one per week, but it's probably not realistic.

    Thank you for your support.

  2. Hello, welcome back. I am very interested in the topic of using Vue in WordPress. I am looking forward to how to setup Vue in WordPress with Webpack which you suggested update in conclusion. Thank you guy.