A Developer's Guide to WordPress
Josh Lee
- Developer since ~2006
- WordPress developer since ~2010
- Have built scores of WordPress websites of all sizes
- Organizer for the Burlington WordPress Meetup
Find Me
WordPress powers 20% of the internet
Accessibility & Extensibility
Core values
Posts
One table to rule them all
In WordPress, Everything is a Post*
* almost
Some built-in Post-Types:
- Post
- Page
- Attachment
Custom Post types let you make your own, e.g.:
- Portfolio Item
- Recipe
- Book
So what about metadata?
Post Meta
Key-value pairs containing data for posts. Can be managed by plugins or sometimes directly by administrators.
User Meta
The same, but for users instead of posts.
Caution:
Either might contain serialized data
Categories & tags
Categories & tags are examples of taxonomies
- You can make your own taxonomies
- Taxonomies can be hierarchical (categories) or not (tags)
- Any taxonomy can be associated with any post type
- Specific items within a taxonomy are called terms
Action Hooks
Almost event listeners
You can attach your own functions to action hooks
WordPress will run your code at the appropriate time
(e.g. upon initialization of the plugin)
Filters are like actions
But the callback takes and returns an argument
Plugins vs. Themes
Themes
Themes must contain an index.php and a style.css
Generally they should be used to provide style and not functionality, but any PHP and hooks are available for developers to use.
Plugins
Plugins have access to the same action hooks as themes, and typically contain functionality changes which might include default styles.
Plugins can also run code upon activation/deactivation
Wait, Just an index.php?
The WordPress Template Hierarchy
If a more specific template does not exist, WordPress will fallback
Sidebars and widgets
Sidebars are just buckets of widgets
WordPress love absolute URLs
*be careful migrating your data - remember that serialized data store in post meta?
A Developer's Guide to WordPress
By Josh Lee
A Developer's Guide to WordPress
- 2,342