1. Custom Post Types and Taxonomies
Jared Atchison
WordPress Developer & Consultant
jaredatchison.com / @jaredatch
3/24/12 Custom Post Types and Taxonomies 1
2. Just who the hell is this guy?
ABOUT ME
3/24/12 Custom Post Types and Taxonomies 2
3. About Me
• 2008 Texas A&M graduate (whoop)
• WordPress developer & consultant
• Featured Genesis developer
• Listed CodePoet
• WordCamp speaker and attendee
• Plugin author
• Custom Metaboxes co-author (CustomMetaboxes.com)
• bbPress contributor, forum moderator
3/24/12 Custom Post Types and Taxonomies 3
4. Let’s begin…
CUSTOM POST TYPES
3/24/12 Custom Post Types and Taxonomies 4
5. First, a quick poll.
• DO YOU KNOW?
• DO YOU USE?
3/24/12 Custom Post Types and Taxonomies 5
7. What the @#$*! is a Custom
Post Type?
Also referred to as CPTs
3/24/12 Custom Post Types and Taxonomies 7
8. CPTs - from the Codex
“WordPress can hold and display many different types of
content. Internally, these are all stored in the same place,
in the wp_posts table.
These are differentiated by a column called post_type.
WordPress 3.0 gives you the capability to add your own
custom post types and to use them in different ways.”
http://codex.wordpress.org/Post_Types
3/24/12 Custom Post Types and Taxonomies 8
9. WP Default Custom Post Types
• Post
• Page
• Attachment
• Revisions
• Nav Menus
3/24/12 Custom Post Types and Taxonomies 9
12. You should really check out the
Codex. No Really.
• Naming best practices
• Reserved names
• Admin UI
• URLs
• CPT templates
• Available $args
http://codex.wordpress.org/Post_Types
http://codex.wordpress.org/Function_Reference/register_post_type
3/24/12 Custom Post Types and Taxonomies 12
13. How and when?
A PSA ON REGISTERING CPTS
3/24/12 Custom Post Types and Taxonomies 13
14. Register when appropriate…
• If at all possible – “Core Functionality” plugin
• http://wpcandy.com/teaches/how-to-create-a-functionality-plugin
• http://ottopress.com/2011/creating-a-site-specific-snippets-plugin/
• http://www.billerickson.net/core-functionality-plugin/
3/24/12 Custom Post Types and Taxonomies 14
15. How? Check.
Where? Check.
WHEN?
3/24/12 Custom Post Types and Taxonomies 15
16. WITH GREAT POWER
COMES GREAT RESPONSIBILITY
3/24/12 Custom Post Types and Taxonomies 16
17. THINK ABOUT HOW IT WILL BE
USED AND WHAT IT NEEDS
3/24/12 Custom Post Types and Taxonomies 17
18. Example
• Books
• Will it be setup different than posts?
• Custom metaboxes?
• Separate taxonomies (authors, genres, rating,
price)
• Separate queries
• Archive page
• No? ?
3/24/12 Custom Post Types and Taxonomies 18
19. Further reading…
http://ottopress.com/2010/wordpress-3-0-and-custom-post-types/
3/24/12 Custom Post Types and Taxonomies 19
22. Books
http://popcritics.com/books/professional-wordpress-plugin-development
3/24/12 Custom Post Types and Taxonomies 22
23. Movies
http://popcritics.com/movies/avatar
3/24/12 Custom Post Types and Taxonomies 23
24. Movies (cont.)
http://popcritics.com/movies
3/24/12 Custom Post Types and Taxonomies 24
25. Beating a dead horse.
SLIDERS, SLIDESHOWS,
ROTATORS.
3/24/12 Custom Post Types and Taxonomies 25
26. Generally there are two different
methods used for a “slideshow”
custom post type…
3/24/12 Custom Post Types and TaxonomiesCustom Post Types and Taxonomies
26
27. First method
• The entire post type is one slideshow
• Each entry (post) is a slide
• Featured image is the slide image
• hierarchial=false (register cpt)
• orderby=menu_order (wp_query)
• Fancy AJAX re-ordering, eg:
http://wordpress.org/extend/plugins/simple-page-ordering/
3/24/12 Custom Post Types and Taxonomies 27
28. First method – back end
3/24/12 Custom Post Types and Taxonomies 28
29. First method – front end
3/24/12 Custom Post Types and Taxonomies 29
30. Second method
• Each entry (post) is a complete slideshow
• Usually has a shortcode system
eg [slideshow id=21]
• Often has more bells and whistles, though can
be more work to customize
3/24/12 Custom Post Types and Taxonomies 30
31. Second method – back end
http://soliloquywp.com/
3/24/12 Custom Post Types and Taxonomies 31
32. … last one… I promise
http://soliloquywp.com/
3/24/12 Custom Post Types and Taxonomies 32
33. Let people know other people like you.
TESTIMONIALS
3/24/12 Custom Post Types and Taxonomies 33
49. bbPress
• One of the most advanced examples of CPTs
• Go for 2.x
• Loads of trickery
• Forums = CPT
• Topics (threads) = CPT
• Replies = CPT
• Topic tags = custom taxonomies
3/24/12 Custom Post Types and Taxonomies 49
53. bbPress in the wild
• www.makeupgeek.com/forums/
• www.getshopped.org/forums/
• www.wpcandy.com/forums/
3/24/12 Custom Post Types and Taxonomies 53
54. Other CPT examples…
• Coupons
• Events (Events Calendar Pro)
• Products (WooCommerce)
• URL Redirection (Simple URLs)
• Bookmarks (formerly like delicious)
• Tutorials
3/24/12 Custom Post Types and Taxonomies 54
55. QUESTIONS? FIND ME.
Jared Atchison
WordPress Developer & Consultant
jaredatchison.com / @jaredatch
3/24/12 Custom Post Types and Taxonomies 55