{"id":2047,"date":"2022-01-19T22:40:19","date_gmt":"2022-01-19T15:40:19","guid":{"rendered":"https:\/\/wptips.dev\/?p=2047"},"modified":"2022-02-17T10:45:33","modified_gmt":"2022-02-17T03:45:33","slug":"im-not-using-timber-anymore-heres-why","status":"publish","type":"post","link":"https:\/\/pixelstudio.id\/blog\/im-not-using-timber-anymore-heres-why\/","title":{"rendered":"I&#8217;m Not Using Timber Anymore \u2013 Here&#8217;s Why"},"content":{"rendered":"\n<p>In the past eight months, I have <strong>stopped using Timber<\/strong> in my WordPress projects.<\/p>\n\n\n\n<p>Hold on to your pitchfork! Let me explain.<\/p>\n\n\n\n<p>It is a great plugin that I have used for seven years. But I feel the downsides outweigh the benefits now.<\/p>\n\n\n\n<p>What are the downsides? Let&#8217;s discuss<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Hard to Find Developers<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"571\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2022\/01\/notimber-hard-find-developer.jpg\" alt=\"\" class=\"wp-image-2052\" srcset=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2022\/01\/notimber-hard-find-developer.jpg 750w, https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2022\/01\/notimber-hard-find-developer-480x365.jpg 480w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><\/figure>\n\n\n\n<p>I&#8217;ve been working solo for the past few years. So whatever niche technology I used didn&#8217;t matter.<\/p>\n\n\n\n<p>Now that I started working as a team, it&#8217;s clear that very few people are using Timber. And those who know how, use it in their own way. <strong>There&#8217;s no standard!<\/strong><\/p>\n\n\n\n<p>I can&#8217;t afford the time to teach them since I&#8217;m working with several freelancers on multiple projects.<\/p>\n\n\n\n<p>It&#8217;s simply <strong>more efficient<\/strong> to use a pure PHP template that everyone knows how to use.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. Hard to Integrate with Some Plugins<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"539\" src=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2022\/01\/notimber-hard-integrate.jpg\" alt=\"\" class=\"wp-image-2051\" srcset=\"https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2022\/01\/notimber-hard-integrate.jpg 750w, https:\/\/pixelstudio.id\/blog\/wp-content\/uploads\/2022\/01\/notimber-hard-integrate-480x345.jpg 480w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><\/figure>\n\n\n\n<p>Try making a WooCommerce store with Timber. It&#8217;s a mess!<\/p>\n\n\n\n<p>There are some resources to help you with integrating WooCommerce such as <a rel=\"noreferrer noopener\" href=\"https:\/\/timber.github.io\/docs\/guides\/woocommerce\/\" target=\"_blank\">the official Timber docs<\/a>. But you can&#8217;t say the same for other plugins.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. We Have Built-in Alternative<\/h2>\n\n\n\n<p>WordPress version 5.5 brought us a very useful upgrade to <code>get_template_part()<\/code>. It has 3rd parameter to pass in an array to the template file.<\/p>\n\n\n\n<p>Yes, it is similar to what <code>Timber::render()<\/code> does. This means you can create a Timber-like structure without any plugin. Here&#8217;s an example:<\/p>\n\n\n\n<pre title=\"index.php\" class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">&lt;?php\nglobal $wp_query;\n\n$args = [\n  'title' =&gt; 'Welcome to my Blog',\n  'posts' =&gt; $wp_query-&gt;get_posts(),\n];\n\nget_header();\nget_template_part('views\/posts', '', $args);\nget_footer();<\/code><\/pre>\n\n\n\n<pre title=\"views\/posts.php\" class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">&lt;main role=\"main\"&gt;\n  &lt;h1&gt;\n    &lt;?php echo $args['title']; ?&gt;\n  &lt;\/h1&gt;\n\n&lt;?php if (count($args['posts']) &gt; 0): ?&gt;\n  &lt;ul class=\"wp-block-latest-posts is-grid columns-3 alignwide\"&gt;\n  &lt;?php foreach ($args['posts'] as $post): ?&gt;\n    &lt;?php setup_postdata($post); ?&gt;\n\n    &lt;li&gt;\n      &lt;?php if (has_post_thumbnail()): ?&gt;\n        &lt;div class=\"wp-block-latest-posts__featured-image\"&gt;\n          &lt;a href=\"&lt;?php the_permalink(); ?&gt;\"&gt;\n            &lt;?php the_post_thumbnail('medium'); ?&gt;\n          &lt;\/a&gt;\n        &lt;\/div&gt;\n      &lt;?php endif; ?&gt;\n\n      &lt;a href=\"&lt;?php the_permalink(); ?&gt;\"&gt;\n        &lt;?php the_title(); ?&gt;\n      &lt;\/a&gt;\n\n      &lt;div class=\"wp-block-latest-posts__post-author\"&gt;\n        by &lt;?php the_author(); ?&gt;\n      &lt;\/div&gt;\n      &lt;time datetime=\"{{ post.post_date }}\"&gt;\n        &lt;?php echo get_the_date(); ?&gt;\n      &lt;\/time&gt;\n      &lt;div class=\"wp-block-latest-posts__post-excerpt\"&gt;\n        &lt;?php the_excerpt(); ?&gt;\n      &lt;\/div&gt;\n    &lt;\/li&gt;\n  &lt;?php endforeach; ?&gt;\n  &lt;\/ul&gt;\n\n&lt;?php else: ?&gt;\n  &lt;h1 class=\"has-text-align-center\"&gt;\n    No Posts Found\n  &lt;\/h1&gt;\n&lt;?php endif; ?&gt;\n&lt;?php wp_reset_postdata(); ?&gt;\n&lt;\/main&gt;<\/code><\/pre>\n\n\n\n<p>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 <code>views<\/code> file.<\/p>\n\n\n\n<p>If you are interested to see a full-fledged theme using this concept, check out my theme called Edje:<\/p>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link\" href=\"https:\/\/github.com\/hrsetyono\/edje-wp-theme\" target=\"_blank\" rel=\"noreferrer noopener\">View Edje Theme in Github<\/a><\/div>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Timber is a great plugin. But we can use <code>get_template_part()<\/code> for the same benefit while avoiding the learning curve and potential incompatibility.<\/p>\n\n\n\n<p>Having a quick onboarding process for new developer or freelancer is also a blessing.<\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>Thank you for reading. If you have any question or rebuttal, feel free to voice your opinion in the comment below<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;s discuss 1. Hard to Find Developers I&#8217;ve been working solo for the past few years. So whatever niche technology I used didn&#8217;t matter. Now that I started working as a team, it&#8217;s clear that very few people are using Timber. And those who know how, use it in their own way. There&#8217;s\u2026<\/p>\n","protected":false},"author":1,"featured_media":2054,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[24],"class_list":["post-2047","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-timber","tag-timber"],"blocksy_meta":"","_links":{"self":[{"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/posts\/2047","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/comments?post=2047"}],"version-history":[{"count":7,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/posts\/2047\/revisions"}],"predecessor-version":[{"id":2078,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/posts\/2047\/revisions\/2078"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/media\/2054"}],"wp:attachment":[{"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/media?parent=2047"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/categories?post=2047"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pixelstudio.id\/blog\/wp-json\/wp\/v2\/tags?post=2047"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}