Chapter 9: Custom Functionality in Theme Functions and Plugins

WordPress is designed to be added to. A vanilla WordPress installation gives you a great deal you can use to build a website, such as the ability to add pages with a hierarchical structure, posts, category and tag archives, menus, widgets, and more. But if you want to take it further (for example, by adding your own custom post types or taxonomies or linking to external APIs such as Google and Twitter), you'll need to include additional functionality. Most sites you build will likely need functionality that isn't included in the core WordPress installation. There are three ways you could do this:

• Use an off-the-shelf plugin, either by downloading a free one from the WordPress plugins repository at http://wordpress.org/extend/plugins/ or by buying a premium one. You can use any plugins you download as is, or you can edit them to meet the needs of your project. But if you do edit a third-party plugin, you won't be able to take advantage of automatic updates for that plugin.

• Write your own plugin.

• Add functionality via the theme's functions.php file.

This chapter assumes that you need to code your own functionality, so you will be using the functions file or your own plugin. The method you choose doesn't affect the result—it's largely the same code, after all; but it does affect the maintainability and flexibility of any site you build, or the scope of a theme or theme framework you're developing.

The first ...

Get WordPress: Pushing the Limits now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.