Skip to content

An Introduction to the WordPress PHP Coding Standards

Coding makes you follow rules – every language has its own syntax to which you have to adhere if you want your code to compile or run.
But there is another set of rules, that while isn’t essential for the actual running the code, helps in peripheral parts of coding. These rules are called Coding Standards.

Coding standards are recommended conventions for writing code. Every language has its own, and WordPress, as a system, has its own version for each of the languages used to build it. WordPress has coding standards for PHP, Accessibility, CSS, HTML, and JavaScript.

This article will focus on the PHP coding standards. Before we dive into the coding standards, you might want to brush up on the PHP language through the PHP for Beginners tutorial, The Essential WordPress Tutorial for PHP Developers, or specifically Understanding PHP’s echo.

Why Follow the WordPress Coding Standards

You might be asking yourself: why would I want to commit to a whole set of new rules that aren’t absolutely needed for writing working code on WordPress. Well, that’s a great question, and one that The WordPress Coding Standards documentation has answered in its introduction:

Coding standards help avoid common coding errors, improve the readability of code, and simplify modification. They ensure that files within the project appear as if they were created by a single person.

Yay! 🎉 You made it to the end of the article!
Lea Cohen
Share:

4 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Pexle Chris
December 13, 2020 2:50 am

Great article. Thank you. I haven’t known some of these best practises!!

JB van der Westhuizen
December 10, 2020 2:05 am

I am new to messing with the WordPress code but I decided that I should learn some PHP. I came across your website and I am starting the “PHP for Beginners: Starting on Back-end WordPress Development” course today.

But I could already see some of the standards just with my limited experience messing with theme’s PHP code.

I’ll keep this in mind while learning.

Or start the conversation in our Facebook group for WordPress professionals. Find answers, share tips, and get help from other WordPress experts. Join now (it’s free)!