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.
Great article. Thank you. I haven’t known some of these best practises!!
Glad you found the article helpful!
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.
Great to hear that, good luck and enjoy!