Thinking in WordPress

WordPress is a handy blogging tool, a useful Content Management System or a capable web application framework. Whatever way you look at it, WordPress helps you solve problems in creative ways. In this article, I want to talk about how I approach projects and my methodology for problem-solving with WordPress. This is not an exhaustive list and one article wouldn’t do justice to the vastness of WordPress. I will try to add whatever pointers stand out among the decisions you would probably have to take.

Defining and breaking down the problem

The first question I tend to ask is “Can WordPress solve this problem?”. Although it’s tempting to think “Yes, it can!”, the reality is it may not be the best solution for all situations. For example, when you want to have an authentication/authorization solution, it would be crazy to use WordPress. Something like .NET’s Identity Server may suit you better. So, when would you use WordPress? The short answer is – whenever you are dealing with content-related problems.

WordPress has reasons why it’s the most popular CMS in the world – covering a third of all websites in the universe. We will discuss why you might have to consider WordPress as a viable contender for your next problem!

Let’s say you chose WordPress, these are the issues/solutions you have to think of next.

Theme or Plugin 

You can use WordPress just like that – but most real-world problems would need you to pick a theme or plugin. For example, when you are building just a WordPress site, you have to define how it’s going to look like. For that, you have to think of a suitable theme – either build, buy or get something for free from the repository. When choosing the theme, think hard of what you’re trying to achieve – perhaps aesthetics, usability or ease of setting up.

Next, you might have to choose a plugin – or multiple plugins. The rule I try to follow is, use the least number of plugins as you can. After choosing ready-made plugins, you have to write your own code within the theme’s functions.php file or within a new plugin of your own.

When to use an MU-Plugin

WordPress has something called Must-Use Plugins. What are they? They are essentially functionalities that are tightly coupled to your site. These plugins cannot be deactivated or uninstalled through the WordPress admin dashboard. They are essentially an easy way of writing PHP code to do whatever you need.

Does it require an app-like experience

This is an important question. Traditional WordPress sites have to refresh its pages each time you click on a link. With the flooding of Single-Page Applications (SPAs), you might be left out if you are using WordPress. Or is it?

With the introduction of WordPress REST API in 2016 (WordPress 4.7), you are able to use a front-end framework for your needs. For example, you will use WordPress just to manage your content and not for displaying the content – taking the role of a headless CMS.

You can also build mobile apps that consume data from WordPress. This is a big win!

REST API or GraphQL

Shortly after REST API was baked into core, Jason Bahl started a really cool project – WPGraphQL which combines two of my favorite things in the world; WordPress and GraphQL.

The advantage of using WPGraphQL over WP REST API is that you get much higher performance. However, what is even more important is the ability to query exactly what you want – you can ask for the post data and author data in just a single call. You had to make two calls using WP REST API to achieve this. The other advantage is that you can ask just for the fields that you need – whereas REST API will give you all the fields for that endpoint. Moreover, you just have a single endpoint; in REST API you had to deal with multiple endpoints depending on what you need to get.

I’m not saying you have to switch to GraphQL from today; merely giving an idea of an interesting project that is out there. This is worth checking out – and who who knows, you might even use it on your next project.

What front-end framework/library to use

Now that you have selected REST API or GraphQL to fetch your data from WordPress – you might be asking the next most important question. Choosing a framework or library is a very difficult question to answer – the answer is almost always “It depends!”. You have to choose what you and your team are most comfortable with and what solved your problem.

However, I’d like to give my (biased) two cents here. If you would later need to build Gutenberg blocks, it might be worth considering React for your project. This is because Gutenberg Blocks are generally built using React and JSX (although there are alternative ways to build them). I have also built a WordPress theme using React and WP REST API – and I call it Celestial.

Disclaimer: choosing a front-end framework/library is not necessary. WordPress can work just as well without it. This section applies if you answered “Yes” to the previous question – Does it require an app-like experience?

If you want to have a static site generated from your content from WordPress, choosing a static site generator is a no-brainer. My favorite is Gatsby – and it seems to be the community’s favorite as well. Gatsby is an application framework that uses React and builds your site for speed, security, SEO and good UX. We are currently porting your favorite WordPress themes over to become Gatsby themes at GatsbyWPThemes.com – the Twenty Nineteen WordPress theme is already ported, so feel free to check it out. I have had very positive experience with Gatsby and can’t recommend it enough. I have also written a whole blog post about my experience with Gatsby + WordPress,

Is a mobile app necessary

The answer really depends on what you or your client is looking to achieve. If for some reason, you decide to have a mobile app, you have to decide how you are going to build it – fully native, hybrid or native cross-platform. I have chosen the native cross-platform approach with React Native and I have to say it’s a welcoming experience – especially if you chose React in the previous step.

I happen to have a mobile app using WooCommerce and React Native – feel free to take a look.

Using third-party plugins

This is a critical question. When you decide to buy a third-party plugin, always look at the credibility of the author that is selling it. If it’s a WooCommerce add-on from Automattic, just buy it – no questions asked. However, if it’s from someone else, read reviews and research their track record. This is important since some plugins have either gone rogue or been abandoned – which becomes a real nuisance once you finish the project using that plugin.

Another question for plugins – if you chose to have a decoupled front-end or a mobile app, see if the plugin has support for REST API (or even a WPGraphQL add-on). Without this, you will end up wasting hours developing your custom endpoints.

Will building a Gutenberg Block solve the issue

It really depends whether you want to have your own blocks developed for the project. If you happen to use so, Create Guten Block by Ahmad Awais can help you greatly with it.

I have a testimonials slider block on the repository – feel free to check out Testimonials Slider Block .

Performance and caching

A very important step in building an all-round site is good performance and caching. Unfortunately, I’m not an expert at these. Check out this page by 10up for more information on Caching best practices.

Accessibility

Another important step for any site to be complete – not just in WordPress. Fortunately, most themes have skip links and aria labels, among other things to consider in accessibility. Check out this page by make.wordpress.org to learn more about a11y in WordPress. Really, any principle for website accessibility applies for a WordPress site too.

SEO

It’s important that your site is searchable on the internet. For this, you can use semantic tags for building your theme among other things.

Note: uncheck the ‘Discourage search engines from indexing this site’ inside Dashboard > Settings > Reading.

Moreover, you can install the Yoast plugin for managing meta tags, canonical URLs and more SEO features for your content.

Hosting options

I have hosted mtwoblog.com on a Digital Ocean $5 plan. It works well for me. If you want a more sophisticated solution, you can check WPEngine or Pantheon. Not an expert at these either, but SiteGround worked well for one of my clients as well.

Conclusion

That was a short list of considerations I think of when using WordPress to solve my problem. Reach out to me on Twitter @muhsinlk if you have more suggestions or want to get in touch with me.

Leave a Reply

Your email address will not be published. Required fields are marked *