WordPress, the content management system the internet loves. You can use it for years without needing to tackle PHP, but eventually you’re finding yourself needing it. You go to Bing and search “php for beginners” and you find yourself here. The journey to learn PHP for WordPress development is long, but let’s start!
We’ll kick off this WordPress coding tutorial with a little summary of PHP’s role in WordPress, and then start to build up from there.
Using PHP in WordPress: Useful for Everyone, Necessary for Developers
You don’t really need to ever write PHP code as a WordPress user, WordPress business owner, or other similar role. A minority of the people who use WordPress on a daily basis even know what PHP is, never mind know how to write code in it. But WordPress developers, WordPress developers must use PHP. But I’m getting ahead of myself…
WordPress Runs atop PHP on the Server
Before we jump fully into our PHP for beginners tutorial, some background:
Web servers, it turns out, are just computers. And those computers need to have underlying layers they can run on. For most WordPress sites, that breaks down to be:
- Linux (the operating system, like Mac OS or Windows),
- Apache (the web server, thing your browser talks to),
- MySQL (the database, where posts live),
- and PHP (which coordinates with the database, OS, and files to build web pages).
I wrote a lot more about this in our “WordPress LAMP” article:
A WordPress LAMP?! An Introduction to WordPress Infrastructure
PHP is a Programming Language
So, hopefully the above made you aware that PHP is something that WordPress uses under the hood. It’s a programming language, and the language that WordPress server-side code is written in. (In the web browser of both administers and visitors, WordPress often also involves languages called HTML, CSS, and JavaScript).
PHP was one of the first and most popular languages that people used to build HTML documents (aka “web pages.”) Its popularity is a little more complex than I want to cover here, but I did write a “Why PHP” article over on Thoughtful Code for those who are interested in that.
In short: PHP is a logic-programming language which you can use to control which HTML a page shows, either in WordPress or outside of it. The files that make up both WordPress themes and plugins are mostly using PHP to build the pages that you see when you visit a WordPress site in your web browser.
Learn PHP for WordPress and You’ll be Able to Modify Themes, Make Plugins
As we just covered, both WordPress plugins and themes use a lot of PHP. (Though in 2022, the amount of PHP you’ll see in themes has just gone down…) Essentially, everything in a plugin is enabled by the PHP code you write. For a
[…]
This article was written by David Hayes and originally published on WPShout.