Cody Helgeson gave a presentation on custom post types in WordPress. He covered best practices for custom post types and taxonomies, using page templates, custom fields, custom columns in the admin interface, and custom queries. Real-world examples were provided and code samples were shown for registering post types and taxonomies, as well as retrieving custom field values and building custom queries.
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Wordcamp Phoenix 2012 - Custom Post Types: Now What? By Cody Helgeson
1. 1
Custom Post Types
Now What?
By Cody Helgeson
WordCamp Phoenix 2012
@codyhelgeson | @fallingupmedia | #wcphx
2. 2
Find More Info
Who Am I?
My Experience with WordPress
@codyhelgeson
@fallingupmedia
fallingupmedia.com
cody@fallingupmedia.com
@codyhelgeson | @fallingupmedia | #wcphx
3. 3
Topics For The Day
• Custom Post Type Best Practices
• Custom Taxonomies
• Page Templates
• Custom Fields
• Custom Admin Columns
• Custom Queries
@codyhelgeson | @fallingupmedia | #wcphx
4. 4
Custom Post Types
• Who has or is about to use custom post types?
• Why use custom post types
• Why not?
• For the client
• For the developer
@codyhelgeson | @fallingupmedia | #wcphx
5. 5
Custom Post Types
Examples
• Book and Product Reviews
• Job and Business Listings
• Events and Locations
• Portfolios and Case Studies
• Combine with BuddyPress for Community Domination!
• Anything your Heart Desires....
@codyhelgeson | @fallingupmedia | #wcphx
6. 6
Custom Post Types
The Code
http://codex.wordpress.org/Function_Reference/register_post_type
• Contextual help menus are a nice touch
• Permalinks matter!
• Flush the rewrite rules, or save permalink settings
• /%category%/%postname%/
• www.domain.com/custom-post-type/post-title
@codyhelgeson | @fallingupmedia | #wcphx
7. 7
Topics For The Day
• Custom Post Type Best Practices
• Custom Taxonomies
• Page Templates
• Custom Fields
• Custom Admin Columns
• Custom Queries
@codyhelgeson | @fallingupmedia | #wcphx
8. 8
Custom Taxonomies
http://codex.wordpress.org/Taxonomies
• Categorizes and groups content
• Hierarchal or not? I.E. tags or categories
• Clean and intuitive for users
• Custom slugs argument
• Create custom page templates and queries
@codyhelgeson | @fallingupmedia | #wcphx
9. 9
Custom Taxonomies
The Code
http://codex.wordpress.org/Function_Reference/register_taxonomy
• Flush rewrite or save permalink settings
• There are reserved terms!
• register_taxonomy($taxonomy, $object_type, $args);
@codyhelgeson | @fallingupmedia | #wcphx
10. 10
Topics For The Day
Custom Post Types
• Custom Post Type Best Practices
• Custom Taxonomies
• Page Templates
• Custom Fields
• Custom Admin Columns
• Custom Queries
@codyhelgeson | @fallingupmedia | #wcphx
11. 11
Page Templates
http://codex.wordpress.org/Template_Hierarchy
• WordPress makes it easy! Use them!
• single-post_type.php
• archive-post_type.php
• taxonomy-taxonomy_name-slug.php
• taxonomy-taxonomy_name.php
@codyhelgeson | @fallingupmedia | #wcphx
12. 12
Topics For The Day
Custom Post Types
• Custom Post Type Best Practices
• Custom Taxonomies
• Page Templates
• Custom Fields
• Custom Admin Columns
• Custom Queries
@codyhelgeson | @fallingupmedia | #wcphx
13. 13
Custom Fields
http://codex.wordpress.org/Custom_Fields
• Purely incredible! Endless possibilities
• Remove what you don’t need from editor. Take the time
• Create your own or use a plugin
• Advanced Custom Fields plugin
• Magic Fields plugin
• get_post_meta - add_post_meta
@codyhelgeson | @fallingupmedia | #wcphx
14. 14
Custom Fields
Examples
• Real world examples on the web......
@codyhelgeson | @fallingupmedia | #wcphx
15. 15
Topics For The Day
Custom Post Types
• Custom Post Type Best Practices
• Custom Taxonomies
• Page Templates
• Custom Fields
• Custom Admin Columns
• Custom Queries
@codyhelgeson | @fallingupmedia | #wcphx