Custom Post Types
In the wild
Mario Peshev@no_fear_inc me.peshev.net
Agenda
• WordPress• Posts and Pages• Custom Post Types• In the wild• Types• Views
About me
• WordPress Engineer at
• DevriX CTO• Open Source trainer
and consultant
70 000 000+ websites
21% of all USAregistered domains now
Posts and Pages
Posts – chronological and archives
Pages – subpages and templates
But in the end...
phpMyAdmin
Post Types
• Post• Page• Attachment• Revision• Nav Menu
But I need a new structure :\
Examples:
Magazine Entries
Products
Real Estates
Slides
Courses
Forms
Air Conditioners
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
CuperFields!
Add extra values to a post
Enable them first!
All post types include...
• Title• Content area• Date• Featured Image• Revisions
Custom Fields
• Specific information for every post• Rating• Phone number
• Everything beyond title, content, featured image, date or taxonomies
Wait, Taxonomies?
Tags
Categories
And... Custom Taxonomies!
Taxonomies
• Great for classification• Drawback:
• Support only title• Can't be extended (naturally)
Post Types simple
Post Types full
Register Taxonomy
The Loop
• The core iteration WordPress unit
List all product titles
Note: always use WP_Query instead.
List all products in a taxonomy term
The Swiss knife of Post Types
Field groups
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
CPT toolkits
• Types• Pods• Advanced Custom Fields• Custom Post Type UI• More Fields
Pro users: go to Views
Views sample site
Views
View Templates
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
Questions?