The path to becoming a skilled developer is long and practically endless. New frameworks and web technologies keep developers on their toes pushing to learn more every year. WordPress is quite possibly the most popular PHP CMS ever made and it powers almost 20% of all self-hosted websites.
If you’re into PHP development this is a system worth learning and mastering. But how do you go about doing so?
In this post I’ll outline the most important areas of WordPress that every developer should understand. It may help to create your own structured WordPress learning curriculum where you study specific areas for a couple weeks or months at a time. This will help maintain your focus and keep you moving through WordPress at a breakneck pace.
Modern WordPress Theming
If you’re brand new to WordPress then it’s worth first learning about the dashboard before getting into the nitty-gritty.
However I’m assuming anyone reading this already understands the fundamental pieces of using WordPress, and really just wants to understand how to write code to build on top of the WordPress platform.
That said, I believe theming is the best place to start. Yes plugins are great, and custom functions are extremely useful. But theming is a requirement for every WordPress site. Whether you’re coding a new theme from scratch or customizing an existing one, you really want to be comfortable with WordPress’ theming system.
The only required files for a theme are the style.css stylesheet and the main index.php. WordPress theming works by conditional files so if you don’t have a homepage.php for the homepage, WordPress defaults to index.php instead. Similarly if your theme doesn’t have author.php for the author archive page you can just use archive.php instead.
WordPress theming is smart and easy to pickup once you learn the hierarchy. Here’s a list of the minimum bare-bones files that I believe should be in every WordPress theme:
- style.css – the theme’s official stylesheet with theme info
- index.php – ultimately the fallback page for anything without a unique theme file
- home.php – your blog’s homepage whether static or archive content
- single.php – a single post/article layout
- page.php – a single page layout
- archive.php – used as a catch-all for archives like categories, tags, authors, and dates
- 404.php – the default 404 error page layout
Note that advanced themes should include more specific files to help define better content & page layout design.
To learn more, check out the template files list in WordPress’ official documentation. WP also offers a handy diagram explaining how theme file hierarchies operate:
Each theme is typically developed as a standalone entity which can offer theme-dependent plugins and functions. All themes are written in PHP so it’s possible to include a theme file that operates like a function library, thus restricting features to a single theme.
Alternatively child theming can work great for building on top of an existing theme. This is a somewhat advanced topic and not everyone likes the idea of child themes because they can grow very complicated very quickly.
I think it’s worth at least understanding how they operate and deciding for yourself if child themes would fit into a certain project.
Basic Plugin Development
The two biggest aspects of WordPress development are themes and plugins. Since theming affects the site’s layout and interface, that really should be your first area of study. The natural follow-up would be delving in plugin development.
Building a WordPress plugin is tough but easy to learn if you practice. There’s enough material online that it shouldn’t be considered much of a hurdle anymore.
It’s worth noting that so many free plugins are available that it’s possible to build WordPress websites with free third party plugins without ever writing your own. However skilled WordPress developers should at least understand how plugins function and how to write one if the need arises.
Two very important terms you should understand are filters and actions. They both take in some code and output/return something, but do so in different ways.
Filters are meant to return code like a string of HTML or a new updated variable. Actions return (or output) code directly into hooks that are predefined in WordPress themes, plugins, or even by the WordPress core
Check out this Stack thread to learn more.
These different methodologies have functions which mirror each other. For example add_action() and add_filter() behave similarly for actions and filters, respectively. This is also true of do_action() and apply_filters().
Plugin development requires a lot of reading and practice. You’ll be confused along the way but that’s part of the learning curve.
I highly recommend this Tuts+ guide covering the basics of actions and filters. WP Engineer also has a great post on defining your own hooks which delves deeper into the process of building fully-functioning themes/plugins that can be extended with code.
Developing Internal Features
WordPress offers a handful of alternate features via internal classes and APIs that are accessible to all developers. Some are rather advanced like the rewrite API or the REST API, but new developers should consider starting with more basic features:
Everyone has their own opinion about the functions.php file. Personally I am a big fan. This file stores theme-specific functions and settings that define how the theme operates through shortcodes, hooks, and filters.
Your theme’s functions file can even have custom PHP functions that you call from within other theme files. Some developers feel this is bad practice but it’s the best way to organize theme-specific functions into one library.
Check out this list of free snippets to get an idea of what’s possible with a theme’s functions.php file.
A shortcode is defined in PHP but can be directly added into content. These are typically denoted with square brackets in the WordPress post/page editor with something like
to build an image gallery.
Check out the shortcodes documentation to see more examples and learn how they operate.
Read more: How to create your own WordPress Shortcodes
Custom Post Types
Before WordPress 3.0 there were only a few default post types: attachments, posts, and pages. These are often more than enough and they work great for the majority of WordPress websites.
But the addition of CPTs allowed developers to create new types like newsletters, eCommerce products, and user-submitted content.
These custom post types can also have their own custom taxonomies beyond the default tags & categories. CPTs can be defined via plugin or in a theme’s functions.php. There’s a lot of flexibility once you learn how these work and how to write your own.
Few developers fully understand the power of custom fields until they start using them. When you write a new post in the admin panel, you’ll notice different widgets for adding tags, categories, a featured image, etc.
Custom fields can be defined to add more widgets onto the page for extra content, known as meta-data. The popular SEO plugin Yoast does this by adding their own custom fields in the post/page section to update the title/meta content.
It’s possible to add a field that stores any type of metadata whether it’s multiple featured images or alternate author bios. The capabilities are limitless once you learn how to build custom fields and put the info to good use.
Advanced WordPress Development & Beyond
The content I’ve already covered might take someone years to master and fully apply to their workflow. WordPress is easy to get started but difficult to master.
Beyond the concepts of theme/plugin development you might try incorporating specific WordPress APIs into your learning list. These topics are really for advanced developers that want to understand everything WordPress has to offer.
Here are a few ideas to get you started:
- Settings API – define custom settings pages and input fields
- Options API – the standard method of storing database content
- Rewrite API – rewrite URLs and make your own custom WordPress permalinks
- Transients API – for storing temporary data in a database cache
- WP_Query – a class for writing custom database queries
- Walker – a class for managing tree data structures such as page hierarchies
Remember that learning is a process that never stops. To become a skilled developer you need consistent effort and a passion for the industry.
If you keep these topics bookmarked and practice regularly I guarantee you’ll learn a lot and find yourself among the ranks of many other professional WordPress developers.