WordPress Tips & Tricks

Vilim Stubičan


Let me share some experiences I got from a couple of years in WordPress.

First things first, public declaration: I hate WordPress. Not as a concept, but because of its core. It’s “outdated”. It was written in a couple of days, and while it has gotten its fair share of rewriting, it’s still a long way from becoming a proper framework (even though that is not its main purpose). Also, I really, really, really, REALLY don’t like procedural programming in 2017.


And that’s a really big BUT!!!.

I love it equally as much. It’s a CMS and a damn easy one. It has the largest community in the world. Period. Last time I checked,  24% of the Internet was running on WordPress. Yes, the Internet. If you are powering that many sites, you are surely gonna have a huge community and you are doing something right. Don’t get me wrong, if I were to write some really serious system or a tool, I would go with some framework (and I have written huge sites in WordPress that copied a lot of functionalities from major players like chats, payment systems, event systems, whole activity/notification based systems, etc.). But if you are looking for a quick and easy solution that just works out of the box, go with WordPress.

One of the main reasons that will tip me over to go with WordPress is whether client asks for the possibility to edit site content. I don’t want to rediscover the wheel and write my own CMS when you have a damn good one that’s free and easy to install.

But ok, let’s get to those tips and tricks.

1. Use community knowledge

This one is kind of obvious. If you have a problem, try googling it. With a community this big, there’s a huge chance that someone already had this problem and solved it. That solution is either a chunk of code that you can use OR a plugin that you can turn on/off.

There’s a plugin for that!!!
– you (after 6 months in WordPress development)

You have all sorts of useful plugins, and here’s a list of some that we use on daily basis:

  • Advanced Custom Fields PRO – this one you should definitely get, it will simplify your custom fields a lot, and it’s only $100, forever, for unlimited projects
  • WPML – makes it super easy to create multilingual sites and also integrates beautifully with ACF
  • InfiniteWP – this is a must-have if you have a lot of sites, you won’t ever have to enter an admin password for a legacy project again
  • Clean image filenames – if you’re using diacritics (like čćšđž), this will rename them so you won’t have encoding problems with some browsers
  • Yoast SEO – don’t bother yourself with meta tags and stuff like that, do it through an easy interface, or let your SEO expert do it! Either way, you don’t have to worry about it (just don’t forget to call wp_head() in your headers ;) )

Ok, my free marketing is done.

( If any of you guys work for any of these guys, send me an email 😎. )

My point being, use that massive accumulated knowledge to which you have free access. Moving on to some more interesting tips.

2. Learn WordPress hierarchy

Ok, maybe not that much more interesting, but still. Proper knowledge on this will save you a lot of time. Here’s a nice image of that hierarchy.

Things like page templates, hierarchy fall-through for custom post types, archives, custom taxonomies, post templates (yes, they also exist and they are exactly like page templates, but for posts and custom post types), etc.

For instance, if you are building a site with breadcrumbs, and your archive pages have a good amount of custom content, don’t go to page templates. Go with archive-{post-type}.php page. You can save your data on the options page and still access it properly. Long term, it is going to be easier to add them (you can just use default breadcrumbs from WP).

Believe me, I have troubled myself with this specific problem too many times.

And check out those post templates. They are really useful for all sorts of stuff. If you are familiar with ACF, you know that you can choose when a group of fields will be shown. On one project we had a multilingual site with a lot of custom fields group where some of those were dependent on categories. We lately realized that this decision was kind of like shooting yourself in the foot. When slugs for these categories were translated, it happened that two different languages had the same slug. This works for rewrite rules and redirects, but the plugin is getting the first result with that slug, meaning that the second language never gets its own group. If post templates were used instead of categories for this group displaying, it would be avoided and making it even better in architecture. Also, these are really cool if one specific post needs to be kinda different than the rest (yes, this can and also will come as a request).

3. Learn WP_Query

I can not tell how important this is. You can get a lot of information with one query, not to mention how much it simplifies fetching data from the database. I have written SQL queries in WordPress on multiple occasions, but I have written them only when I couldn’t solve that specific problem through one of the WP_Query classes (you also have WP_Term_Query and WP_Comments_Query).

Also, you have a bunch of neat features and possibilities in it.

If you have worked on several projects, chances are that you had to implement some kind of related or recommended posts display (you know, you are on some blog post and then you have those three/five smaller links to other blog posts). You basically have three ways of implementing this:

  1. Let editor/admin decide which ones are going be displayed here (multiple select with other posts)
  2. Show same three on all posts (ok, without the one that is being displayed)
  3. Display random values every time a page is visited

But there is this cool option for random order in WP_Query’s order by definition which is pulled directly from MySQL. You can write something like this:

RAND(seed) will “randomly” order your results depending on the seed. If you take post’s ID as a seed, you should get a unique order for every post every time you visit it. That’s cool.

One more really cool thing is that WordPress is using this same class for its internal query. Meaning, if you need to implement a filter on some archive page, you can use these params directly through your URL, appending query variables exactly as they are in WP_Query.  WordPress will use those for internal filtering and you might avoid any sort of filtering by your own hand. Note: this is applicable only if you are not required to use pretty links. :)

But also, you need to be careful with how you use it.

If you are doing a lot of filtering with post meta, that means that you are getting a LEFT JOIN for every single meta value comparison you added. This can get really tricky if you have a huge database (like some legacy project). When we had this case, we actually built a custom query which filtered our post IDs and then used WP_Query to extract those posts.

The difference in speed was huge: 15s for WP_Query’s meta filter and 0.2s for our custom query and then WP_Query. We got to this discovery with our following tip.

4. Dive deep into core code

Don’t be afraid to open that core, being it WordPress core or plugin core. There’s a lot of sharing (and love ❤) between community members through plugins and core specifics, but one thing is not so often there when we need it: proper documentation. You won’t believe how often you can not find some information about something you are using. When in that case, go into core. Open those files and find your answer.

I have inspected so many hooks so far that I probably know their line number in their files. You will also learn the core much better this way (experience > learning). Use xDebug for this (and for every other type of inspection), not var_dump and die. You will leave something behind. I can confirm that from multiple occasions.

This is exactly the same for plugins. Did you know that mail sent from Divi theme builder’s contact form is sending headers as “From: {user name} <mail@{your-domain}>”? And that that will make Postmark plugin which sends emails fail?

You probably don’t have that mail in your sender signature list (if you do, screw you, you lucky bastard). This is the exact type of problem that you will find when you go into the core code of stuff. And then you can fix it.

5. Contribute to the community

If you have found some problem and solved it, tell the world about it. Someone is going to have that same problem someday soon. Make it easier for them. We are all in the same game.

Write a plugin.

Publish a blog post.

Make a pull request with a solution.

Send a report to the code owner.

Post in public groups on social networks.

Do anything that will help others. Also, the community will really appreciate it and you will get recognized in it.

6. Organize your architecture

Make a decision depending on the architecture of your code. Do something that will make your life easier.

Our team started with WordPress roughly 2 and a half years ago from the current date. This week we are publishing our 78th site live. When we started, there were but a two of us. Today we count six members of our “WP team” (with 7th pending) and we can jump into each other’s project with ease. I know exactly everything about the architecture from the first look.

We had situations where one colleague was working on a project and he got ill so someone had to take over his project. PMs thought that there was going to be an introduction period while I take over his project, but I just jumped in, got the tasks and started working on it with no problem. Two days later, he came back and took the project back with no problems at all.

This was accomplished with the proper definition of file structures and code organization. We are currently maintaining all those sites and it takes us minimal time (like, it takes 2-3 hours per week per person to maintain all his/her sites). Not to mention how easy it is to jump in for someone (that also makes PMs really happy since they can organize us more efficiently around projects, which means more money 💰💵💰).



Right now, I can’t remember anything else, but if something comes to my mind, I will write another post.


P.S. You learn something every day. I just noticed that if you write WordPress with lowercase p, it will automatically be transformed to capital P (and I am one of those guys that write WordPress with lowercase p).
Wow, WordPress, wow.


Vilim Stubičan

Code enthusiast that considers there is no such thing as limitation in developer’s mind. Also, writes Typescript and documentation. 🐤

All stories by Vilim


Get more digital stories directly in your inbox.
Your email is saved
Join the discussion

1 Comment



One of my favorite article with tips, great job

Share your thoughts

Our sister, the digital innovation company, has been launched. Visit Bornfight.com
Let's work together  →
Go to top