acf domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/jwblogger/jwBlogger/wp-includes/functions.php on line 6121wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. This notice was triggered by the codepen-embed-script handle. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.) in /home/jwblogger/jwBlogger/wp-includes/functions.php on line 6121Without Twig, here is the code you need to write to display an image:
$thumb_id = get_post_thumbnail_id($post->ID); $url = wp_get_attachment_url($thumb_id); <img src="<?php echo $url; ?>" alt="Thumbnail for <?php echo $post->post_title; ?>" />
And thats just for a thumbnail image. Imagine using this code to show a gallery of images, or if you had to use a srcset attribute to ensure the appropriate image gets loaded, given the user’s screen size.
With Timber, that code now looks like:
<img src="{{post.thumbnail.src}}" alt="Thumbnail for {{ post.title }}" />
Much cleaner and concise, yes? Ref: https://www.upstatement.com/timber/#object-oriented-posts-etc
Getting started with Timber was way easy. I followed the steps in “Setup” tutorial with no problem – I love tools that come with clear and unambiguous instructions.
The first time I installed Timber, I installed the plugin found on WordPress.org, Then I downloaded the Timber starter theme so I could begin to play with the templates. No other configuration was necessary.
Next Step is to invite NPM and Gulp into our theme and start compiling our styles with SASS!
]]>Therefore, I want to demonstrate how to leverage modern technologies like Gulp and Twig so that WordPress Theme development is cleaner and smoother.
Note that I am definitely not an expert here. I am only trying to explain my experiences in becoming a better WordPress developer. Reading documentation is crucial, but almost equally as important accounts from people who tried similar things as what I’m trying to do, even if the post is a few years outdated and/or not the best solution. For me, its all about perspective!
Ultimately, I want to do less PHP and focus more on front end development, usability, and Even though WordPress is PHP based, I am going to use NodeJS and Gulp to compile and manage my CSS and JS assets. I will use Zurb’s Foundation for my front end framework to assist in my layout and presentation, and Timber, which will let me create Twig templates.
I am assuming anyone reading this post is familiar with SASS, Twig, and the importance of modular web design.
First, lets make HTML development easier with Timber and Twig. Twig is whats called a Template Engine, and its a way to marry the structure of a webpage to it’s data, or content. Timber is a plugin that allows Twig to be used with WordPress.
See WordPress Development with Twig and Timber
Then I’ll show how I organize and isolate my styles, and use Gulp and a CSS preprocessor (like SASS) to compile those styles into a single CSS file. Also, I’ll demonstrate how to use SASS to customize a CSS Framework like Bootstrap or Foundation.
See Leveraging SASS in WordPress Development and Customizing Foundation for a WordPress Theme
Finally, I’ll use Gulp again to manage, compile, and minify my Javascrript assets. I like having separate Javascript files for each widget / component found on the site, then compiling those files into a single scripts file.
(Blog post coming soon)
My motivation here is to demonstrate how I use the work of others to improve my own WordPress development and create some sense of modularity. I haven’t discovered anything unique here, I am simply showing how to use existing tools like Gulp and Twig to improve my WordPress development.
]]>I have a love hate relationship with WordPress. I love that it is responsible for so much web content. I love how it has been a pioneer for content management systems, making it easier for your average human to publish content to the web. I love the fact that I’ve had many projects that leveraged WordPress, and that I played a small role in helping my clients do business.
But from a technical and professional perspective, WordPress is frustrating to work with. As a front end developer, who likes to have control over HTML and layout containers, I find it difficult to develop creative solutions to unique problems. Sure WordPress is very extensible – there are tons of free plugins and themes that can extend WordPress and ensure no two WordPress sites will be the same. But that also means that a WordPress site can easily become bloated with an entangled mess of codependent code, putting the site at risk of slow load times, data errors, and even hacks.

In my WordPress development experiences, ambiguity is a recipe for disaster. Yes, ambiguity is a factor in any project, but it seems to be much less manageable on WordPress projects. Unless the design of a website has been fully flushed out – all the layouts, all the content containers, all the look and feel of buttons and form inputs – unless all of that has been flushed out and agreed upon by the client before any code is written, the project will face ambiguity. Sure, part of my job as a developer is to be able to handle that ambiguity gracefully. I have to be flexible, and build the project carefully, and anticipate changes that might come in the 11th hour of the project. However, I’ve always found it difficult to be flexible in WordPress projects.
I often wonder is it possible to build a WordPress site using a modular design approach?
As a kid, I liked building with Lincoln Logs and Legos1. I like building one piece at a time, then merging the independent pieces at the end. I like to build websites in a similar way. By breaking a website project down to a group of independent modules (such as navigation, form elements, article layouts, etc.), I create the flexibility needed to anticipate changes in the design, or unforeseen UI/UX hiccups that no one considered when the project started.
I avoided WordPress for the longest time because it was just too time consuming to make a site flexible enough to evolve over time. Most of my WordPress development was fixing broken elements, cleaning up code bloat, or scrapping hours of work and starting from scratch after the client suddenly decided to do something different. Sometimes I would spend months developing a site only to have it break a few weeks after launching because of some automatic update, or the client tried to do something I didn’t anticipate. These are common obstacles when developing any website, but when dealing with WordPress, these obstacles were a nightmare. WordPress development did not feel like building with Legos, it felt like trying to stay afloat in a sinking ship.
My point is, WP is a great tool when working with small websites, but its difficult to do unique and creative work, which isn’t fun. I’d like to continue using WordPress, given its popularity, but I also want to enjoy performing the work I do, and thats difficult to do when using WordPress. Specifically, as a developer using WordPress, I find it difficult to:
– Manage CSS, both global styles and page/widget specific styles.
– Manage script and style includes. I mean, why should I have to load assets for Contact Form 7 on every page if theres only one page containing a form?
– Create and extend page templates. I’m an HTML enthusiast. I don’t want to drown in a bunch of PHP templates and functions and hooks just to get the HTML I want.
– And don’t get me started on custom fields and custom post types. I am so grateful for plugins like ACF and CPT because I still have nightmares about trying to create custom WP sites without those tools.
I could go on and on here. I don’t mean to complain, all content management systems are quirky and no CMS will please everyone.
WP is constantly improving, and most importantly, is free. For that I am thankful. However, given the popularity of WordPress, I cannnot avoid it, and that makes me frustrated. I am a Front End Developer. I want to write clean HTML, Javascript, and CSS, and build useful web interfaces that create value for my clients. I like PHP, but I don’t want to live in it. Can I do that using a CMS that is also easy to use for the end user? I am sure I am not the only front end developer who wonders about a better developer-friendly way of working with WordPress
About Using Modular Approach in Front End Development
I certainly don’t mean any disrespect to WordPress. In fact, I hear WordPress 5.0 is about to be a thing, so I look forward to learning a new generation of WordPress.
For now, I wish to present my current WordPress setup. I have learned how to leverage Gulp and Twig to aide in my WordPress development, and I wish to share that. Stay tune…
]]>