WordPress is an excellent tool for building and running a site, fast. It is also one of the best CMSs out there, which is solid and easy to employ. WordPress has stayed a top choice among other CMSs because it allows for multi-users and multi-blogging, and because it’s a free open source platform of course.

It does leave room for mistakes though, and even the most proficient developers have their uh-oh moments in which they stash all their JavaScript into a single file, or forget to change the default permalink structure. It happens, and every mistake is an opportunity to learn. Here we have a few of the most common WordPress mistakes, just to give you a heads up, whether you’re a pro or a beginner:

1. Putting WordPress theme JavaScript code into one file

Oh my, oh my. Using a premium theme with all the libraries and custom code stored into one sole file is not a good option. This because, the file, after a while, gets really big. As the theme is continuously developed and acquires new features it can grow up to even 1MB in size. Unfortunately, the file will be loaded across the site even if 8% of the code is used on some pages. This will cause pages to download and pre historic speeds and slower to render, especially if the code is render-blocking in the head section of the page. Also, it gets harder to manage the code contained in the file, as you cannot turn to wp_dequeue_script() to clear out some of the code in some pages to optimize the speed or prevent a conflict with other JavaScript code present.

2. Giving names that are too generic

This is the moment to unleash some creativity. When developing a plugin, it’s smarter to use names that will not cause code conflict in the event there are other plugins with the same name. Plus, it also makes things easier to find when you have your own unique naming system.

But, sometimes in projects, you’ll have to abide by existing coding style, unless you’re working on something separate from the current one. If you must extend an existing plugin or theme that already abides by PHP coding standards for WordPress, then it’s a better idea to stay with them to maintain consistency and clean, easy to read code. There are some universal rules to optimize performance, apart from coding styles, such as using single quotes instead of double ones, and indenting code to be read, especially if we’re talking about nested code

3. Not taking full advantage of WordPress’ Core Functionality

WordPress has continuously updated libraries by their development core team, take advantage of this core functionality for lighter and easier to look-after project. By regularly updating WordPress, you have access to more components such as plugins and themes, or a WordPress core, and allow the website to be more secure in the event old code releases present vulnerabilities.

4. Not allowing for plugins to be easy to modify

Let’s start by saying altering a WordPress plugin or theme, in general, is not a good idea unless you are contributing to the development of its package and working on its code. If by accident an automatic update is carried out on the edited plugin or theme, all changes will be eliminated and you have to perform all the changes from scratch again. What fun.

That’s why using actions and filters, as well as using a child theme, are safer bets rather than altering the parent theme or plugin. Also, if you’re providing a free downloadable plugin on WordPress.org and afterward you’d like to produce a premium extension that would rely on the parent plugin, then it’s better to create the free plugin in a manner that it would be simple to extend and add premium extensions to.

5. Writing PHP code without taking into account the page could be cached in the future

Stick to the PHP coding standards and you can easily prevent this type of mistake. Often developers have the nasty habit of integrating PHP snippets into themes and plugins that are only working if the PHP code is enabled all the time.

In the event a client installs a plugin that caches the page (i.e. WP Rocket) without enabling the conditionals in your theme or plugins, your PHP code will be made useless. So to prevent this from happening, make the pages responsive on the front-end part with media queries and JavaScript and only write PHP code in back-end if necessary. If possible, avoid all together using JavaScript to make your site responsive.

6. Not using a version control system to track changes

Make sure child themes or custom plugins or any files that are custom-coded are under version control. Git, for example, records changes and helps developers work together on the same WordPress project or reset back to a previous version with ease if anything happens with the website. Furthermore, clients get the chance with Git to view all the work history done by the developers hired for the particular project, especially if it was a big and long-term WordPress tailored website. Even though it may be a little tricky to understand Git at first, it will be worth the extra time.

7. Enqueuing when not necessary

Enqueuing CSS and JavaScript files when not necessary is counterproductive. Having lots of HTTP requests makes the website sluggish to load, causing it to have a lower ranking in Google search. It may also spur JavaScript errors due to conflict amongst plugins, such as two using a shared jQuery library, which could be loaded two times and lead to problems.

WAD Author

Connect with >8,000 participants, >300 tech companies & startups and >100 speakers from >50 countries. Experience the latest technologies and innovations on the market and participate in workshops, round tables, and interactive sessions with the world’s leading developers and IT experts.

LEARN MORE