The 14 Worst Mistakes Advanced WordPress Developers Make

Slået op d. - Sidst ændret d.

Wordpress has continued to be one of the most popular ways to set up a site and make it operational quickly. But the fact Wordpress can be used to set up sites at speed often causes developers to make mistakes as they do so. Mistakes such as setting WP_Debug to true are quite common,  or bundling javascript into a single file. There are many simple traps to fall into. Read on to discover the 14 most common mistakes Wordpress developers make.

1. The Wordpress theme javascript code being placed into a single main file

Some people will keep all the libraries, along with the custom code, in a single file - often referred to as custom,js or mai.js,theme. This is not good practice for the reasons highlighted below.

  1. Over time, the file may grow significantly due to the increase in features. Some files which may be as large as 1MB. Almost all of it will be loaded though only 10 % of the file’s code is required on certain pages. This means the rendering of the page will be slower, and downloading will take longer. This is especially the case if the render-blocking code of the page is located in its head section.

  2. Managing the code inside the file will become much harder. You will not be able to use files like wp_dequeue_script() for unloading certain parts of the code on specific pages, to improve its speed. There may be conflict with Javascript code loading via one of the active plugins. Granted, you may split the file into multiple files and queue it in Wordpress, but  this process will have to be repeated if the main,js file of the theme is updated by the website admin at a later date.

2. Assigning names to functions, classes, variables or constants that are too common

When coming up with a plugin, using a name that does not conflict with other plugins is always advisable. Developers often add prefixes to the names of their variables and functions to make them unique. It prevents code conflict, and makes it easier to find plugins when you have many enabled.

3. Modifying the core code

This is a cardinal sin which should be avoided at all costs. It can lead to a wide range of issues such as invalid bug reports, ineffective theme and plugin installs and you may lose changes to any updates made.

4. Forgetting to maximize the true potential of the WordPress Core Functionality

WordPress has a suite of libraries which are updated on a regular basis. These can be found in your plugins and themes. It is advisable to make use of the core functionality, because some WordPress plugins and themes have asset directories which contain files that are already part of the core files in WordPress. Using core files will stop the package getting bigger than it needs to - and so keep loading times down -  and save you updating third-party libraries on a regular basis.

5. Not ensuring the plugin or theme can easily be altered using actions and filters

It is not a good idea to edit a WordPress theme or plugin directly if you are not behind the development and distribution of the package and code. You will be forced to edit the files from scratch if the plugin or theme is updated automatically, as the direct changes will be lost. To avoid this, you can use actions and filters, including creating Child Themes, which let you alter the current functionality while avoiding editing the parent plugin or theme.

6. Development of Wordpress sites while WP_DEBUG which is set to false

In WordPress, the WP_DEBUG is by default set to ‘false’ in order to prevent printing PHP errors, along with warnings and notices. This is better when developing in a live environment, since it hides scripts and private server paths from the public. But it should be set to ‘true’ during development so it can notify you of errors in the code as they arise.

If you want to learn more about projects pertaining to Wordpress development, you can check freelancer, where many Wordpress specialists can be found.

7. Writing PHP Code while disregarding the fact that the page may be cached at a later date

You should stick to PHP coding standards if you want to avoid this. If your client installs a plugin that does not trigger your plugin or theme’s conditionals but caches your page, your PHP code will be useless. This is what you can expect if you implement PHP snippets into plugins and themes that are only valid when the PHP code is triggered.

8. Failing to track changes in a professional manner

Failing to track changes may mean other developers won’t want to work with you. You might also have to repeat changes you’ve already made to the code. Keeping clear track of changes you make will avoid this. Try using Git, as this tool keeps track of whatever changes are made to a specific WordPress project.

9. Including JavaScript and CSS files even when they are not required - having too many HTTP requests

This often makes websites slower to load and results in a lower rank in Google’s PageSpeed. It may also have an impact on search engine ranking, and cause javascript errors.

10. Outputting Javascript or CSS Code by means of .php rather than .js and Static .css

This is a bad practice as it causes numerous issues. For example, performance issues arise because the browser has to download the complete file prior to rendering the page. Developers will find it harder to read the PHP file code when they need to check something. The best way to avoid these issues is to avoid saving CSS inside the plugin directory.

11. Not using the appropriate code organization for WordPress Themes and Plugins

Check the nature and type of plugin you are dealing with before choosing the code organization. The code organization depends on the size and nature of the plugin. Plugins and themes may either stand alone, or use extensions that require triggering the main plugin before they can work.

12. Overlooking the importance of WordPress security when writing code

The website you are developing may at risk of being hacked or having your plugin published if you fail to take this into account. The latter may render thousands of websites vulnerable. Deal with security issues such as XSS vulnerability, preventing direct access to your code, using Nonces (protects URLs from misuse or external attacks).

13. Using an admin to post content

For security reasons, it is not advisable to use the admin when posting or developing content. It makes it easy for intruders to log into your system. Instead, use a freshly created contributor account when coming up with content.

14. Making use of WordPress code snippets and functions without understanding what they are all about

Developers may get stuck, and simply take advantage of solutions from sources such as Stackflow to come up with something that works - even though they may not fully understand the code. This has numerous cons, such as:

  • The code may not use the same style as that of the current project, leading to style inconsistency

  • The code may feature ineffective functions, leading to a website which is slower and harder to maintain

  • Legal issues may arise if the code is not available for reuse

There is no need to despair if you find yourself committing one of these mistakes. Many developers around the world have done so before you - and mistakes can provide you with the opportunity to learn, and become a better Wordpress developer.

Are you a WordPress expert? Feel free to comment on any information found in the article.

Oprettet 22 august, 2017


Software Developer

Lucy is the Development & Programming Correspondent for She is currently based in Sydney.

Næste artikel

9 Important Skills For Entrepreneurship