custom post types in the wild (wordcamp sofia 2012)
DESCRIPTION
My session on Custom Post Types at WTRANSCRIPT
![Page 1: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/1.jpg)
Custom Post Types
In the wild
Mario Peshev@no_fear_inc me.peshev.net
![Page 2: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/2.jpg)
Agenda
• WordPress• Posts and Pages• Custom Post Types• In the wild• Types• Views
![Page 3: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/3.jpg)
About me
• WordPress Engineer at
• DevriX CTO• Open Source trainer
and consultant
![Page 4: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/4.jpg)
70 000 000+ websites
![Page 5: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/5.jpg)
21% of all USAregistered domains now
![Page 6: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/6.jpg)
Posts and Pages
![Page 7: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/7.jpg)
Posts – chronological and archives
![Page 8: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/8.jpg)
Pages – subpages and templates
![Page 9: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/9.jpg)
But in the end...
![Page 10: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/10.jpg)
phpMyAdmin
![Page 11: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/11.jpg)
Post Types
• Post• Page• Attachment• Revision• Nav Menu
![Page 12: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/12.jpg)
![Page 13: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/13.jpg)
But I need a new structure :\
![Page 14: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/14.jpg)
![Page 15: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/15.jpg)
Examples:
![Page 16: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/16.jpg)
Magazine Entries
![Page 17: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/17.jpg)
Products
![Page 18: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/18.jpg)
Real Estates
![Page 19: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/19.jpg)
Slides
![Page 20: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/20.jpg)
Courses
![Page 21: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/21.jpg)
Forms
![Page 22: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/22.jpg)
Air Conditioners
![Page 23: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/23.jpg)
What's the difference
• Unique styling for a post type• Separate categorization• List only post type entries• Common API for all post types• The magic Custom Fields
![Page 24: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/24.jpg)
CuperFields!
![Page 25: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/25.jpg)
Add extra values to a post
![Page 26: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/26.jpg)
Enable them first!
![Page 27: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/27.jpg)
All post types include...
• Title• Content area• Date• Featured Image• Revisions
![Page 28: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/28.jpg)
Custom Fields
• Specific information for every post• Rating• Phone number
• Everything beyond title, content, featured image, date or taxonomies
![Page 29: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/29.jpg)
Wait, Taxonomies?
![Page 30: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/30.jpg)
Tags
![Page 31: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/31.jpg)
Categories
![Page 32: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/32.jpg)
And... Custom Taxonomies!
![Page 33: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/33.jpg)
![Page 34: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/34.jpg)
Taxonomies
• Great for classification• Drawback:
• Support only title• Can't be extended (naturally)
![Page 35: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/35.jpg)
Post Types simple
![Page 36: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/36.jpg)
Post Types full
![Page 37: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/37.jpg)
Register Taxonomy
![Page 38: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/38.jpg)
The Loop
• The core iteration WordPress unit
![Page 39: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/39.jpg)
List all product titles
Note: always use WP_Query instead.
![Page 40: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/40.jpg)
List all products in a taxonomy term
![Page 41: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/41.jpg)
The Swiss knife of Post Types
![Page 42: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/42.jpg)
![Page 43: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/43.jpg)
![Page 44: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/44.jpg)
![Page 45: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/45.jpg)
Field groups
![Page 46: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/46.jpg)
Types Range
• Types could define:• Post type structure• Taxonomies and relations• Custom field groups per post type• Extra custom fields
• Loop is to be done manually
![Page 47: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/47.jpg)
CPT toolkits
• Types• Pods• Advanced Custom Fields• Custom Post Type UI• More Fields
![Page 48: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/48.jpg)
Pro users: go to Views
![Page 49: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/49.jpg)
Views sample site
![Page 50: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/50.jpg)
Views
![Page 51: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/51.jpg)
View Templates
![Page 52: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/52.jpg)
Views Disclaimer
• Warning: Views is not free, it's $49 for unlimited number of websites
• How come?• Complete LOOP control with UI• Create templates for post types and archives• Submit CPTs from the front end• Widgetized loops
![Page 53: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/53.jpg)
![Page 54: Custom Post Types in the wild (WordCamp Sofia 2012)](https://reader034.vdocuments.net/reader034/viewer/2022051322/540bec7d8d7f72f36a8b4981/html5/thumbnails/54.jpg)
Questions?