CONTENTS
INTRODUCTION xxv
CHAPTER 1: FIRST POST 1
What Is WordPress? 1
A Short History: WordPress and Friends 2
Current State 2
Intersecting the Community 3
WordPress and the GPL 4
Content and Conversation 5
WordPress as a Content Management System 5
Creating Conversation 6
Getting Started 7
Hosting Options 7
Do It Yourself Installation 9
Installing WordPress Files 9
Database Configuration 12
Finishing Up 16
First-Time Administration 16
First Post 17
CHAPTER 2: FUNCTIONAL OVERVIEW 19
The Dashboard 19
Dashboard Widgets 20
Customizing the Dashboard 21
Screen Options 21
Admin Menu 22
Creating and Managing Content 22
Creating Posts 22
Managing Posts 24
Creating Pages 25
Managing Pages 25
Links 25
Trash 26
Categorizing Your Content 26
Categories versus Tags 26
Post Categories 27
CONTENTS
Tagging Posts 27
Categorizing Links 28
Working with Media 28
Media Library 28
Uploading Media 28
Inserting Media 29
Managing Media 30
Edit Media 30
Comments and Discussion 31
Managing Comments 31
Moderating Comments 32
Handling Comment Spam 32
Working with Users 33
Creating New Users 33
Managing Users 33
User Roles and Permissions 34
User Images 34
Extending User Profiles 35
Extending WordPress 35
Themes 35
Managing Themes 35
Adding New Themes 36
Upgrading a Theme 36
Using the Theme Editor 37
Working with Widgets 37
Plugins 38
Managing Plugins 38
Adding New Plugins 38
Upgrading a Plugin 38
Using the Plugin Editor 39
Content Tools 39
Importing Content 39
Exporting Content 40
Turbo 40
Upgrading WordPress 40
Configuring WordPress 41
General Settings 41
Writing and Reading 42
Discussion 44
Media 44
xiv
CONTENTS
Privacy 45
Permalinks 45
Miscellaneous 46
CHAPTER 3: CODE OVERVIEW 49
Downloading 49
Download Locations 49
Available Formats 50
Release Archive 50
Exploring the Code 50
Configuring Key Files 51
wp-config.php file 52
Advanced wp-config Options 53
.htaccess 58
Enabling Permalinks 58
.htaccess Rewriting Rules 59
Configuration Control Through .htaccess 60
The .maintenance File 61
WP-Content User Playground 61
Plugins 61
Themes 62
Uploads and Media Directory 62
Upgrade Directory 63
Custom Directories 63
CHAPTER 4: TOUR OF THE CORE 65
What’s in the Core? 65
Using the Core as a Reference 66
Inline Documentation 67
Finding Functions 67
Exploring the Code 70
Functions.php 70
Formatting.php 70
Pluggable.php 70
Plugin.php 71
Post.php 71
Category.php 71
WordPress Codex and Resources 72
What Is the Codex? 72
Using the Codex 72
xv
CONTENTS
Function Reference 73
WordPress APIs 74
Codex Controversy 75
Don’t Hack Core! 76
Why Not? 76
Alternatives to Hacking Core 76
CHAPTER 5: THE LOOP 79
Understanding the Loop 80
Putting the Loop in Context 81
Flow of the Loop 81
Template Tags 84
Commonly Used Template Tags 84
Tag Parameters 85
Customizing the Loop 86
Using the WP_Query Object 86
Building A Custom Query 87
Post Parameters 87
Page Parameters 88
Category, Tag, and Author Parameters 88
Time, Date, Ordering, and Custom Parameters 88
Putting It Together 89
Adding Paging To A Loop 89
Using query_posts() 90
Using get_posts() 92
Resetting a Query 93
More Than One Loop 94
Nested Loops 94
Multi-Pass Loops 95
Global Variables 95
Post Data 95
Author Data 96
User Data 96
Environmental Data 97
Global Variables or Template Tags? 98
Working Outside the Loop 98
CHAPTER 6: DATA MANAGEMENT 103
Database Schema 103
Table Structure 104
xvi
CONTENTS
Table Details 105
WordPress Database Class 107
Simple Database Queries 107
Complex Database Operations 108
Dealing With Errors 110
Direct Database Manipulation 111
WordPress Taxonomy 114
Default Taxonomies 114
Taxonomy Table Structure 115
Understanding Taxonomy Relationships 115
Building Your Own Taxonomies 116
Custom Taxonomy Overview 116
Building Custom Taxonomies 116
Using Your Custom Taxonomy 119
CHAPTER 7: PLUGIN DEVELOPMENT 121
Plugin Packaging 121
Create a Plugin File 122
Creating the Plugin Header 122
Plugin License 123
Activate and Deactivate Functions 123
Internationalization 124
Directory Constants 126
Know Your Hooks: Actions and Filters 127
Actions and Filters 127
Popular Filter Hooks 129
Popular Action Hooks 130
Plugin Settings 132
Saving Plugin Options 132
Array of Options 133
Create a Menu and Submenus 134
Creating a Top-Level Menu 134
Adding To An Existing Menu 135
Create an Options Page 136
WordPress Integration 143
Create a Meta Box 143
Shortcodes 147
Create a Widget 148
Create a Dashboard Widget 152
xvii
CONTENTS
Creating Custom Tables 153
Uninstall Your Plugin 155
Plugin Security 157
Nonces 157
Data Validation 158
Creating a Plugin Example 160
Publish to the Plugin Directory 175
Restrictions 175
Submit Your Plugin 175
Create a readme.txt File 176
Setup SVN 179
Publish to the Plugin Directory 180
Releasing a New Version 181
CHAPTER 8: THEME DEVELOPMENT 183
Why Use a Theme? 183
Installing a Theme 184
FTP Installation 184
Theme Installer 185
What Is a Theme? 185
Template Files 185
CSS 186
Images and Assets 186
Plugins 186
Creating Your Own Theme 187
Starting from a Working Theme 187
Starting with the Sandbox Theme 187
Creating Your Own Theme: Getting Started 189
Essential File: Style.css 190
Showing Your Content: Index.php 191
Showing Your Content in Different Ways: Index.php 193
Creating Your Own Theme: DRY 193
Header.php 194
Footer.php 195
Sidebar.php 195
Deviations from the Norm: Conditional Tags 196
xviii
CONTENTS
Creating Your Own Theme: Content Display 197
Customizing Your Homepage: home.php 197
Show Your Older Posts by Date: Archive.php 200
Showing Only One Category: Category.php 201
Show Posts of a Specific Tag: Tag.php 202
How to Show a Single Post: single.php 203
Display a Page: Page.php 204
Display an Image from Your Gallery: Image.php 206
Template Hierarchy 206
Creating Your Own Theme: Additional Files 208
Handle 404 Errors: 404.php 208
Attachment.php 209
Author.php 210
Comments.php 210
Add Functionality to Your Templates: Functions.php 211
Search.php 214
SearchForm.php 215
Other Files 215
Custom Page Templates 216
When to Use Custom Page Templates 216
How to Use Custom Page Templates 217
Stock Sandbox Page Templates 218
Theme Hierarchy and Child Themes 219
Premium Themes and Other Theme Frameworks 224
Revolution Theme 225
Hybrid Theme 225
Thematic Theme 226
Thesis Theme 226
Sandbox Theme 226
Partial Themes 226
CHAPTER 9: CONTENT AGGREGATION 229
What is a Lifestream? 229
Getting Noticed 230
Social Media Buttons 231
Simple Social Networking Badges 232
xix
CONTENTS
Collecting External Content 233
Generic XML Feed 233
Integrating Twitter 236
Google Maps 238
Integrating RSS and ATOM Feeds 239
Pushing Content from WordPress to Other Sites 240
Feeding RSS into Other Sites 240
Feeding WordPress into Facebook 241
Advertising 242
Monetizing Your Site 242
Setting Up Advertising 243
Using Advertising Plugins 243
Manual Advertising Placement 245
Dealing With Conflict 246
Privacy and History 247
CHAPTER 10: CRAFTING A USER EXPERIENCE 249
User Experience Principles 249
Consistent Navigation 250
Visual Design Elements 251
Making Content Easy to Find 253
Site Load Times 254
Using JavaScript 255
Usability and Usability Testing 256
Structuring Your Information 257
Getting Your Site Found 259
Duplicate Content 261
Trackbacks and Pings 263
Tags and Content Sharing Sites 264
How Web Standards Get Your Data Discovered 264
Semantic HTML 264
Valid HTML 266
Microformats 267
Searching Your Own Site 269
Weaknesses of the Default Search 269
Alternatives and Plugins to Help 270
Mobile Access 271
xx
CONTENTS
CHAPTER 11: STATISTICS, SCALABILITY, SECURITY, AND SPAM 273
Statistics Counters 273
AWStats 274
Statcounter 275
Mint 276
Google Analytics 276
Cache Management 278
WordPress System Complexity 279
Web Server Caching and Optimization 281
WordPress Object Caching 283
MySQL Query Cache 284
Load Balancing Your WordPress Site 284
Dealing With Spam 286
Comment Moderation and CAPTCHAs 286
Automating Spam Detection 287
Securing Your WordPress Site 288
Stay Up-to-Date 288
Hiding WordPress Version Information 289
Don’t Use the Admin Account 289
Change Your Table Prefix 290
Move Your Configuration File 290
Move Your Content Directory 290
Use the Secret Key Feature 291
Force SSL on Login and Admin 291
Apache Permissions 291
MySQL Credentials 292
Recommended Security Plugins 292
WP Security Scan 292
WordPress Exploit Scanner 292
WordPress File Monitor 293
Using WordPress Roles 294
Subscriber Role 295
Contributor Role 295
Author Role 295
Editor Role 295
Administrator Role 296
xxi
CONTENTS
Role Overview 296
Extending Roles 297
CHAPTER 12: WORDPRESS AS A CONTENT MANAGEMENT SYSTEM 299
Defining Content Management 299
Workflow and Delegation 301
User Roles and Delegation 301
Workflow 302
Content Organization 303
Theme and Widget Support 304
Homepages 305
Featured Content Pages 306
Content Hierarchy 308
Interactivity Features 312
Forums 312
Forms 313
E-Commerce 313
Other Content Management Systems 313
WordPress Integration 314
Where Not to Use WordPress 314
CHAPTER 13: WORDPRESS IN THE ENTERPRISE 317
Is WordPress Right for Your Enterprise? 317
When WordPress Isn’t Right for You 319
Scalability 319
Performance Tuning 320
Caching 321
Regular Maintenance 322
Hardware Scaling 322
Integration with Enterprise Identity Management 324
LDAP and Active Directory 324
OpenID 325
Content Integration via Feeds 326
CHAPTER 14: MIGRATING TO WORDPRESS 329
Planning a Migration 330
Content Sources 330
Migration Checklist 331
Site Preparation 332
xxii
CONTENTS
Content Identification 332
Migrating Text Documents 333
Built-In WordPress Import Tools 333
Blog Conversion 333
Using WordPress eXtended RSS Files 334
Building a Custom Import Script 335
Media Migration 344
Moving Metadata 345
Moving Authors and Users 345
Theme and Presentation 346
Unique Functionality 346
Cleaning Up 346
Manual Fine-Tuning 347
Import Limitations 347
Updating URLs 347
Redirection 348
Launching 349
CHAPTER 15: WORDPRESS DEVELOPER COMMUNITY 351
Contributing to WordPress 351
Understanding Trac 351
Bug Reporting 352
Trac Keywords 353
View and Search Tickets 353
Trac Timeline 354
Browsing Source 354
Working on the Core 355
Understanding Subversion (SVN) 355
Hook into WordPress Core 355
Create a patch/diff File 355
Submitting Plugins and Themes 356
Documentation 356
Sister Projects 357
WordPress MU 357
BuddyPress 357
bbPress 357
Future Projects 358
Resources 358
Codex 358
Support Forums 358
xxiii
CONTENTS
WordPress Chat 359
Mailing Lists 359
External Resources 361
WordCamp and Meetups 361
WordPress.TV 361
Theme/Plugin Directories 362
WordPress Ideas 362
WordPress Development Updates 362
WordPress Podcasts 362
WordPress Weekly 362
WordCast Podcast 363
The WordPress Podcast 363
Plugins: The WordPress Plugins Podcast 363
WordPress News Sites 363
WPTavern.com 363
WPVibe.com 363
WeblogToolsCollection.com 363
WPEngineer.com 364
WordPress Alltop 364
WordPress Planet 364
Planet WordPress 364
INDEX 365