WordPress Development Best Practices — Rise Marketing

​As the strongest open-source content management system (CMS) available on the web today, WordPress lets designers and developers customize websites with great depth. Understanding the ins and outs of WordPress development gives you more room to impress clients, bid for better projects, and strengthen your overall skill set.

It’s vital that you adopt good practices right from the beginning of your journey with this platform. This is going to be of tremendous value to your career as you build in this CMS and further hone your WordPress development skills.

There are literally hundreds of WordPress tutorials you can read online and hours and hours you can spend on that alone. Our aim in this guide is to cut through that complexity and directly give you the actionable information you need to help you get started on this platform as easily as possible.

Follow WordPress Coding Standards

The platform’s coding standards were established for a reason: to provide those in the WordPress community with a starting point for working together within different parts of this community. This includes areas like plugins, themes and core code.

Follow WordPress Coding Standards
Image Credit: Jehyuh Sung

When all developers follow the same standards, the benefits include:

  • Code that’s more readable
  • Avoiding typical coding mistakes
  • Simplifying modification

Because the platform is a collaborative one, it makes sense to create an environment where, if so required, a section of code can be understood and modified, irrespective of when it was written and by whom.

Long story short: If you’re serious about developing on this CMS and want to get far in your career, then this is the most fundamental rule you should follow right out of the gate.

Write Your Code Well

Writing code well involves these principles:

  • Readability – Adhere to the aforementioned WordPress Coding Standards
  • Reliability – Ensure your code does the same thing repeatedly without fail by using WordPress APIs
  • Reusability – Instead of copying and pasting code snippets, abstract your code; beyond that, package the code into a separate plugin
  • Flexibility – Utilize relative URL paths wherever you can to ensure that it can be edited in the future
  • Extensibility – Add a few well-placed action and filter hooks, so others can use what you’ve built and add to it

Structure Your Code Well

Structuring code ensures that it’s readable, easy to find, and consistent. Here are some basic principles:

  • File structure – Ensure that a single file only contains a single PHP class to facilitate better organization
  • Separation & spaces – Put spaces after commas and before beginning parentheses and then after closing parentheses; ensure no closing PHP tags; take away whitespace at the end of code; only put spaces around array items when they’re variable (more info in WordPress’ PHP coding standards)
  • Software design patterns – Learn and familiarize yourself with PHP design patterns by googling the term or browsing through a PHP pattern library

Test Your Code Thoroughly

Not all professionals working in WordPress development test their code or even bother with basic debugging, which is a mistake. For more info on the basics of debugging, here’s a classic video from WordPress.tv.

Dedicated WordPress developers should rely on an IDE such as PHPStorm and consider running something like Xdebug, a debugger for the platform.

For those of you building premium themes or plugins, it’s advisable to test out your code in as many environments as you can. Have users beta-test the code, or use something like Vagrant to test precise configurations through virtual machines.

Test Your Code Thoroughly
Image Credit: Joshua Aragon

Other approaches to consider are unit testing and quality assurance.

Unit testing is useful if you’re building a software as a service (SaaS) offering or a software product. Here, individual pieces of code are tested, and this approach lets you identify early on if something you’ve changed ended up breaking the code. As a result, you’re more likely to catch bugs, nip them in the bud, and avoid shipping code that has bugs to your end users. Here’s some information from WordPress about how it deals with unit testing.

In WordPress development, quality assurance relates to ensuring that code works correctly and that your user interfaces show up properly in browsers. A generally time-intensive process, quality assurance means having somebody look at your site or app in each browser and on each device available. Two invaluable tools to make this time-consuming procedure a bit more efficient are Selenium and BrowserStack.

Select Plugins Wisely

You have a large selection of third-party themes and plugins from which to choose in your quest to optimize the content you offer on your site.

One of the golden rules of WordPress development is to be discerning with the plugins you select: Go with the ones that are regularly updated and feature high satisfaction ratings from users. Not only do regular updates indicate that the plugin’s developer is committed to keeping it compatible with the newest versions of WordPress, but you stand a greater chance of receiving help from them if you ever run into any problems with their code.

Select Plugins Wisely
Image Credit: Host Sorter

Another tip involves taking a look at the plugin’s user base. A dependable measure of the plugin’s effectiveness, many active installations (in the thousands) of the plugin indicate that there are many other developers who have had success installing it.

Having said all of that…

Go Easy on the Plugins

Sure, WordPress has a plethora of plugins, and they can improve the usability and UX of a site, but…don’t go overboard when it comes to them. If you install too many, your site is going to drastically slow down due to the longer load times it takes to deal with all of these extra plugins. And in today’s world, no one wants to wait a long time to use a site. According to research from Google, 53% of the people visiting your mobile site will leave if it takes longer than just three seconds to load a page.

To avoid having such an unwieldy site, only use plugins when it’s really crucial.

Go Easy on the Plugins
Image Credit: Daria Nepriakhina

Of course, sometimes, you can’t just work with a few plugins. What happens if you need to work with a lot? In such a scenario, at least make sure that you’re on top of what you’re using. Something like Plugin Organizer is valuable when it comes to efficiently installing and managing your plugins. You can use it to specify which plugins you have active on which specific webpages. This selective loading should help to speed up your site.

Simultaneously, a tool like P3 (Plugin Performance Profiler) is indispensable when it comes to determining the plugins that are exhausting your site’s vital resources and therefore slowing it down.

Make Use of Caching

This is an approach that can help you significantly speed up your site’s performance, which should help you minimize your bounce rate. If you’re working with a host that features WordPress-specific caching, that’s great, but if not, you can also use hosting services optimized for this CMS, such as Wpengine and Siteground.

Make Use of Caching
Image Credit: Campaign Creators

If you’re on a VPS server that has root access, Google PageSpeed is a caching solution that’s compatible with nginx and Apache.

Alternately, for those who don’t want to put in all that work, there’s always Cloudflare, the CDN and caching service.

Make Security Job One

The web is a dangerous place. There’s an entire mishmash of bots, users and services that want to access your site maliciously. Undesirable access covers things like:

  • Spam comments
  • Bots that send excessive site traffic with the goal of taking your site down
  • Spam login attempts

Fortunately, taking extra security precautions in WordPress development isn’t difficult.

Make Security Job One
Image Credit: Collin Armstrong

For starters, go with a secure username as well as password. Avoid simple names and easy-to-guess passwords for complex ones that include a combination of letters, numbers and special characters.

Utilize Captcha or another filtering approach on forms. As a result, spammers and bots won’t be able to as effortlessly send repeat requests to said forms.

Take advantage of security plugins and services. Security plugins such as All In One WP Security & Firewall and iThemes Security handle fake login attempts, keep track of user activity, offer whitelisting and blacklisting features, and stop brute force attackers.

Try These WordPress Development Tips

Learning WordPress development can be daunting for anyone just starting out on the platform. That’s because there’s a plethora of information to absorb; even those with years of development experience on this platform don’t stop learning. Developing on this CMS is really an ongoing education process that’ll take time for you to feel comfortable working with it.

This topic covers many related areas, and the technical knowledge you’ll need is often best learned through experience as opposed to book-learning.

That said, these best practices will give you a solid footing to understand how to work well within this platform, but they should serve to stoke your curiosity further for all that you can do on this platform.

Kahl Orr
Founder, Rise

Kahl is an entrepreneur, web developer, and the founder of Rise, a digital marketing agency that specializes in web design. Rise builds high-performing, custom websites and apps for some of the fastest-growing national brands.

Like this article?

Join our newsletter to become a better digital marketer.


Write a response...