custom post types in the wild (wordcamp sofia 2012)

54
Custom Post Types In the wild Mario Peshev @no_fear_inc me.peshev.net

Upload: mario-peshev

Post on 06-Sep-2014

2.964 views

Category:

Documents


1 download

DESCRIPTION

My session on Custom Post Types at W

TRANSCRIPT

Page 1: Custom Post Types in the wild (WordCamp Sofia 2012)

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)

Agenda

• WordPress• Posts and Pages• Custom Post Types• In the wild• Types• Views

Page 3: Custom Post Types in the wild (WordCamp Sofia 2012)

About me

• WordPress Engineer at  

• DevriX CTO• Open Source trainer 

and consultant

Page 4: Custom Post Types in the wild (WordCamp Sofia 2012)

70 000 000+ websites

Page 5: Custom Post Types in the wild (WordCamp Sofia 2012)

21% of all USA­registered domains now

Page 6: Custom Post Types in the wild (WordCamp Sofia 2012)

Posts and Pages

Page 7: Custom Post Types in the wild (WordCamp Sofia 2012)

Posts – chronological and archives

Page 8: Custom Post Types in the wild (WordCamp Sofia 2012)

Pages – subpages and templates

Page 9: Custom Post Types in the wild (WordCamp Sofia 2012)

But in the end...

Page 10: Custom Post Types in the wild (WordCamp Sofia 2012)

phpMyAdmin 

Page 11: Custom Post Types in the wild (WordCamp Sofia 2012)

Post Types

• Post• Page• Attachment• Revision• Nav Menu

Page 12: Custom Post Types in the wild (WordCamp Sofia 2012)
Page 13: Custom Post Types in the wild (WordCamp Sofia 2012)

But I need a new structure :\

Page 14: Custom Post Types in the wild (WordCamp Sofia 2012)
Page 15: Custom Post Types in the wild (WordCamp Sofia 2012)

Examples:

Page 16: Custom Post Types in the wild (WordCamp Sofia 2012)

Magazine Entries

Page 17: Custom Post Types in the wild (WordCamp Sofia 2012)

Products

Page 18: Custom Post Types in the wild (WordCamp Sofia 2012)

Real Estates

Page 19: Custom Post Types in the wild (WordCamp Sofia 2012)

Slides

Page 20: Custom Post Types in the wild (WordCamp Sofia 2012)

Courses

Page 21: Custom Post Types in the wild (WordCamp Sofia 2012)

Forms

Page 22: Custom Post Types in the wild (WordCamp Sofia 2012)

Air Conditioners 

Page 23: Custom Post Types in the wild (WordCamp Sofia 2012)

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)

CuperFields!

Page 25: Custom Post Types in the wild (WordCamp Sofia 2012)

Add extra values to a post

Page 26: Custom Post Types in the wild (WordCamp Sofia 2012)

Enable them first!

Page 27: Custom Post Types in the wild (WordCamp Sofia 2012)

All post types include...

• Title• Content area• Date• Featured Image• Revisions

Page 28: Custom Post Types in the wild (WordCamp Sofia 2012)

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)

Wait, Taxonomies?

Page 30: Custom Post Types in the wild (WordCamp Sofia 2012)

Tags

Page 31: Custom Post Types in the wild (WordCamp Sofia 2012)

Categories

Page 32: Custom Post Types in the wild (WordCamp Sofia 2012)

And... Custom Taxonomies!

Page 33: Custom Post Types in the wild (WordCamp Sofia 2012)
Page 34: Custom Post Types in the wild (WordCamp Sofia 2012)

Taxonomies

• Great for classification• Drawback:

• Support only title• Can't be extended (naturally)

Page 35: Custom Post Types in the wild (WordCamp Sofia 2012)

Post Types ­ simple

Page 36: Custom Post Types in the wild (WordCamp Sofia 2012)

Post Types ­ full

Page 37: Custom Post Types in the wild (WordCamp Sofia 2012)

Register Taxonomy

Page 38: Custom Post Types in the wild (WordCamp Sofia 2012)

The Loop

• The core iteration WordPress unit

Page 39: Custom Post Types in the wild (WordCamp Sofia 2012)

List all product titles

Note: always use WP_Query instead. 

Page 40: Custom Post Types in the wild (WordCamp Sofia 2012)

List all products in a taxonomy term

Page 41: Custom Post Types in the wild (WordCamp Sofia 2012)

The Swiss knife of Post Types

Page 42: Custom Post Types in the wild (WordCamp Sofia 2012)
Page 43: Custom Post Types in the wild (WordCamp Sofia 2012)
Page 44: Custom Post Types in the wild (WordCamp Sofia 2012)
Page 45: Custom Post Types in the wild (WordCamp Sofia 2012)

Field groups

Page 46: Custom Post Types in the wild (WordCamp Sofia 2012)

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)

CPT toolkits

• Types• Pods• Advanced Custom Fields• Custom Post Type UI• More Fields

Page 48: Custom Post Types in the wild (WordCamp Sofia 2012)

Pro users: go to Views

Page 49: Custom Post Types in the wild (WordCamp Sofia 2012)

Views sample site

Page 50: Custom Post Types in the wild (WordCamp Sofia 2012)

Views

Page 51: Custom Post Types in the wild (WordCamp Sofia 2012)

View Templates

Page 52: Custom Post Types in the wild (WordCamp Sofia 2012)

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)
Page 54: Custom Post Types in the wild (WordCamp Sofia 2012)

Questions?