SlideShare a Scribd company logo
WordPress Custom Post Types In-Depth
    Colin Vernon & Joachim Kudish
Organizing Content of
Different Types

•   It’s about Content: websites usually have
    content of different types: posts, pages,
    articles, videos, newsletters, products,
    books, anything

•   A question of content and information
    architecture
    vs data structure
Back in the day...

 •   Websites were simpler... ?

 •   Created custom architecture with pages

 •   Different content types could be “faked” with
     categories and category navigation
Custom Post Types in Depth at WordCamp Montreal
Custom Post Types in Depth at WordCamp Montreal
What are custom post
types?


•   Introduced in WordPress 2.9, much
    simplified in 3.0 and expanded upon in 3.1

•   Classic blog format used categories to
    classify content

•   Custom post types allow for more in-depth
    fine-grained control and separation of
    content

•   Better name = custom content type
Advanced uses of CPTs



•   Products (WP E-Commerce uses it -
    http://getshopped.org/)

•   Job Postings

•   Testimonials

•   Newsletters

•   Possibilities are endless!
Custom Post Types in Depth at WordCamp Montreal
Custom Post Types in Depth at WordCamp Montreal
Registering Custom Post
Types
 Graphical/easy way:

  •   Plug and play, simple interfaces

  •   Custom Post Type UI - http://
      wordpress.org/extend/plugins/custom-
      post-type-ui/

  •   GD Custom Posts And Taxonomies Tools
      - http://wordpress.org/extend/plugins/
      gd-taxonomies-tools/

  •   More Types - http://wordpress.org/
      extend/plugins/more-types/

  •   Lots of other examples
Custom Post Types in Depth at WordCamp Montreal
Custom Post Types in Depth at WordCamp Montreal
Custom Post Types in Depth at WordCamp Montreal
GRAPHICAL


  ≠
   USER
INTERFACE
Code Method



 register_post_type();

  •   http://codex.wordpress.org/
      Function_Reference/register_post_type

  •   core function

  •   lots of $args for lots of possibilities
http://pastie.org/2169751 (taken from the WP Codex)
$args = customization
Admin:

 •   labels, show_ui, show_in_menu,
     menu_position, menu_icon,
     capability_type, capabilities,
     map_meta_cap, register_meta_box_cb,
     can_export, show_in_nav_menus

Front-end:

 •   public, publicly_queryable,
     exclude_from_search, hierarchical,
     taxonomies

Permalinks:
Code = Good ☺


•   versionable (svn, git, etc...)

•   core WordPress way

•   easy to edit at any time

•   you keep full control

•   similar to what GUI plugins do,
    but without relying on the database

•   only a few lines of code
Some Shortcomings of
WP API



 •   lots of repetition in the code

 •   not good enough defaults (labels!)

 •   now has good support for archives (since
     3.1) but still no built-in support for feed
     permalinks, etc.
Alternate Code Methods
•   Smarter Custom Post Types by Matt Wiebe:


    •   http://somadesign.ca/projects/smarter-
        custom-post-types/

    •   now obsolete because of 3.1’s archive/
        permalinks abilities

•   Our own SLD Custom Content & Taxonomy

    •   https://github.com/jkudish/SLD-
        Custom-Post-Types-Taxonomies-for-
        Wordpress

    •   wrapper plugin/class for
Taking CPTs even
further
•   Taxonomies

    •   further way of classifying content

    •   group different content types together
        based on taxonomies

    •   use built-in taxonomies (categories &
        tags) or custom taxonomies

    •   register custom taxonomies with code,
        not GUI plugins

    •   use the core WP function
        register_taxonomy()
        http://codex.wordpress.org/
        Function_Reference/register_taxonomy
Custom Post Types in Depth at WordCamp Montreal
http://pastie.org/2170028
Taking CPTs even
further

•   Meta fields / meta boxes / custom fields:

    •   allow you to store any information

    •   extremely expandable

    •   WordPress API requires a lot of code, no
        good defaults:

        •   add_meta_box()

        •   http://codex.wordpress.org/
            Function_Reference/add_meta_box
Custom Post Types in Depth at WordCamp Montreal
Meta Boxes
•   similarly to content types & taxonomies,
    there are GUI plugins to register meta
    boxes

    •   More Fields: http://wordpress.org/
        extend/plugins/more-fields/

    •   Advanced Custom Fields: http://
        wordpress.org/extend/plugins/
        advanced-custom-fields/

    •   Verve Meta Boxes: http://
        wordpress.org/extend/plugins/verve-
        meta-boxes/
Easier Meta Fields


 •   Custom Metadata Manager by Mohammad
     Jangda

 •   http://wordpress.org/extend/plugins/
     custom-metadata/

 •   easy wrapper functions for adding meta
     boxes and custom fields
Custom Metadata
Manager
x_add_metadata_field(
 $slug,
 $object_types = 'post',
 $args = array()
 )
x_add_metadata_group(
 $slug,
 $object_types = 'post',
 $args = array()
 )
Even Further...
•   complex post to post (content to content)
    relations

    •   allows web app functionality à la Rails/
        Django

    •   posts 2 posts plugin: http://
        wordpress.org/extend/plugins/posts-to-
        posts/

•   different page/content templates = different
    set of fields
✔ Lessons Learned

•   use custom content types for anything that
    isn’t a blog post and isn’t a static page

•   if you’re a developer, don’t rely on the
    database to register CPTs

•   if you’re not a developer, hire a developer,
    learn to code (copy/paste) or use a plugin

•   best way to learn = read the codex, code and
    make mistakes
Extra links


 •   Custom post type & custom taxonomy
     generator: http://themergency.com/
     generators/

 •   Joachim’s WP.org profile page (the SLD
     helper class plugin will appear here once it’s
     live): http://profiles.wordpress.org/users/
     jkudish

 •   Colin’s WP.org profile page: http://
     profiles.wordpress.org/users/cvernon

 •   WordPress.tv (recorded presentation will
     appear here): http://wordpress.tv/
Thanks!
Any Questions?
Thanks!
       Any Questions?




http://stresslim.it/welovewp


@stresslimit /   http://stresslimitdesign.com

@jkudish /   http://jkudish.com
Thanks!
Any Questions?

More Related Content

PDF
Becoming a better WordPress Developer
PPTX
The Way to Theme Enlightenment
PPTX
Creating Customizable Widgets for Unpredictable Needs
PPTX
Shortcodes vs Widgets: Which one and how?
PPTX
WordPress Theme Development: Part 2
KEY
doing_it_right() with WordPress
KEY
Extending Custom Post Types
PPT
jQuery Tips Tricks Trivia
Becoming a better WordPress Developer
The Way to Theme Enlightenment
Creating Customizable Widgets for Unpredictable Needs
Shortcodes vs Widgets: Which one and how?
WordPress Theme Development: Part 2
doing_it_right() with WordPress
Extending Custom Post Types
jQuery Tips Tricks Trivia

What's hot (20)

PPTX
Custom WordPress theme development
PPTX
WordPress theme development from scratch : ICT MeetUp 2013 Nepal
PPTX
Introduction to Plugin Programming, WordCamp Miami 2011
PPSX
Extending WordPress
PDF
Custom Fields & Custom Metaboxes Overview
PDF
How to start developing apps for Firefox OS
PDF
Intro to WordPress theme development
PPTX
The Way to Theme Enlightenment 2017
PPTX
Put a little Backbone in your WordPress
PPTX
Introduction to Custom WordPress Themeing
KEY
Advanced WordPress Development Environments
PDF
WordPress Theme Development for Designers
PDF
Theming 101
PDF
WordPress Theme Structure
PDF
Associations & JavaScript
PPTX
Javascript for the c# developer
PDF
Ingo Muschenetz: Titanium Studio Deep Dive
PDF
WordPress as the Backbone(.js)
PPTX
Jquery fundamentals
PDF
OpenERP and Perl
Custom WordPress theme development
WordPress theme development from scratch : ICT MeetUp 2013 Nepal
Introduction to Plugin Programming, WordCamp Miami 2011
Extending WordPress
Custom Fields & Custom Metaboxes Overview
How to start developing apps for Firefox OS
Intro to WordPress theme development
The Way to Theme Enlightenment 2017
Put a little Backbone in your WordPress
Introduction to Custom WordPress Themeing
Advanced WordPress Development Environments
WordPress Theme Development for Designers
Theming 101
WordPress Theme Structure
Associations & JavaScript
Javascript for the c# developer
Ingo Muschenetz: Titanium Studio Deep Dive
WordPress as the Backbone(.js)
Jquery fundamentals
OpenERP and Perl
Ad

Viewers also liked (10)

PPSX
Workshop 4: IJssel-Vechtdelta lessons learned
PPTX
Custom Post Types and Taxonomies
KEY
WordPress 3 Custom Post Types
PDF
Step by step guide for creating wordpress plugin
PPTX
Anatomy and Architecture of a WordPress Theme
PPTX
Architecture for WordPress on AWS
PDF
WordPress Code Architecture
PDF
WordCamp Ireland - 40 tips for WordPress Optimization
ODP
Beginning WordPress Plugin Development
PDF
Wordpress Plugin Development Short Tutorial
Workshop 4: IJssel-Vechtdelta lessons learned
Custom Post Types and Taxonomies
WordPress 3 Custom Post Types
Step by step guide for creating wordpress plugin
Anatomy and Architecture of a WordPress Theme
Architecture for WordPress on AWS
WordPress Code Architecture
WordCamp Ireland - 40 tips for WordPress Optimization
Beginning WordPress Plugin Development
Wordpress Plugin Development Short Tutorial
Ad

Similar to Custom Post Types in Depth at WordCamp Montreal (20)

KEY
WordPress can do that?!
KEY
WordPress - Open Source Overview Presentation
PPT
WordPress Complete Tutorial
PPTX
The Flexibility of WordPress
PPTX
The WordPress University 2012
PPTX
The WordPress University
KEY
Open Source CMS Playroom
PPTX
From WordPress With Love
ZIP
WordPress as a CMS
PDF
Wordpress beyond blogging
PPTX
WCBos13 intermediate workshop
PPTX
Starting WordPress Theme Review
PPTX
PluginBasicsWCNYC2014
PPTX
Wordpress overview
PDF
The WordPress Way
PDF
WordPress A CMS for Beginners, Geeks and Those In-Between
PDF
WordPress Theme Reviewers Team
PPT
Newspapers with WordPress
PPTX
Websites With Wordpress
PPTX
WordPress Workshop
WordPress can do that?!
WordPress - Open Source Overview Presentation
WordPress Complete Tutorial
The Flexibility of WordPress
The WordPress University 2012
The WordPress University
Open Source CMS Playroom
From WordPress With Love
WordPress as a CMS
Wordpress beyond blogging
WCBos13 intermediate workshop
Starting WordPress Theme Review
PluginBasicsWCNYC2014
Wordpress overview
The WordPress Way
WordPress A CMS for Beginners, Geeks and Those In-Between
WordPress Theme Reviewers Team
Newspapers with WordPress
Websites With Wordpress
WordPress Workshop

Recently uploaded (20)

PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Approach and Philosophy of On baking technology
PDF
KodekX | Application Modernization Development
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Cloud computing and distributed systems.
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Machine learning based COVID-19 study performance prediction
PDF
Network Security Unit 5.pdf for BCA BBA.
PPT
Teaching material agriculture food technology
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPTX
Big Data Technologies - Introduction.pptx
PPTX
A Presentation on Artificial Intelligence
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
The Rise and Fall of 3GPP – Time for a Sabbatical?
Encapsulation_ Review paper, used for researhc scholars
Mobile App Security Testing_ A Comprehensive Guide.pdf
The AUB Centre for AI in Media Proposal.docx
Approach and Philosophy of On baking technology
KodekX | Application Modernization Development
“AI and Expert System Decision Support & Business Intelligence Systems”
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Cloud computing and distributed systems.
Dropbox Q2 2025 Financial Results & Investor Presentation
Per capita expenditure prediction using model stacking based on satellite ima...
Machine learning based COVID-19 study performance prediction
Network Security Unit 5.pdf for BCA BBA.
Teaching material agriculture food technology
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Big Data Technologies - Introduction.pptx
A Presentation on Artificial Intelligence
Review of recent advances in non-invasive hemoglobin estimation
Building Integrated photovoltaic BIPV_UPV.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing

Custom Post Types in Depth at WordCamp Montreal

  • 1. WordPress Custom Post Types In-Depth Colin Vernon & Joachim Kudish
  • 2. Organizing Content of Different Types • It’s about Content: websites usually have content of different types: posts, pages, articles, videos, newsletters, products, books, anything • A question of content and information architecture vs data structure
  • 3. Back in the day... • Websites were simpler... ? • Created custom architecture with pages • Different content types could be “faked” with categories and category navigation
  • 6. What are custom post types? • Introduced in WordPress 2.9, much simplified in 3.0 and expanded upon in 3.1 • Classic blog format used categories to classify content • Custom post types allow for more in-depth fine-grained control and separation of content • Better name = custom content type
  • 7. Advanced uses of CPTs • Products (WP E-Commerce uses it - http://getshopped.org/) • Job Postings • Testimonials • Newsletters • Possibilities are endless!
  • 10. Registering Custom Post Types Graphical/easy way: • Plug and play, simple interfaces • Custom Post Type UI - http:// wordpress.org/extend/plugins/custom- post-type-ui/ • GD Custom Posts And Taxonomies Tools - http://wordpress.org/extend/plugins/ gd-taxonomies-tools/ • More Types - http://wordpress.org/ extend/plugins/more-types/ • Lots of other examples
  • 14. GRAPHICAL ≠ USER INTERFACE
  • 15. Code Method register_post_type(); • http://codex.wordpress.org/ Function_Reference/register_post_type • core function • lots of $args for lots of possibilities
  • 17. $args = customization Admin: • labels, show_ui, show_in_menu, menu_position, menu_icon, capability_type, capabilities, map_meta_cap, register_meta_box_cb, can_export, show_in_nav_menus Front-end: • public, publicly_queryable, exclude_from_search, hierarchical, taxonomies Permalinks:
  • 18. Code = Good ☺ • versionable (svn, git, etc...) • core WordPress way • easy to edit at any time • you keep full control • similar to what GUI plugins do, but without relying on the database • only a few lines of code
  • 19. Some Shortcomings of WP API • lots of repetition in the code • not good enough defaults (labels!) • now has good support for archives (since 3.1) but still no built-in support for feed permalinks, etc.
  • 20. Alternate Code Methods • Smarter Custom Post Types by Matt Wiebe: • http://somadesign.ca/projects/smarter- custom-post-types/ • now obsolete because of 3.1’s archive/ permalinks abilities • Our own SLD Custom Content & Taxonomy • https://github.com/jkudish/SLD- Custom-Post-Types-Taxonomies-for- Wordpress • wrapper plugin/class for
  • 21. Taking CPTs even further • Taxonomies • further way of classifying content • group different content types together based on taxonomies • use built-in taxonomies (categories & tags) or custom taxonomies • register custom taxonomies with code, not GUI plugins • use the core WP function register_taxonomy() http://codex.wordpress.org/ Function_Reference/register_taxonomy
  • 24. Taking CPTs even further • Meta fields / meta boxes / custom fields: • allow you to store any information • extremely expandable • WordPress API requires a lot of code, no good defaults: • add_meta_box() • http://codex.wordpress.org/ Function_Reference/add_meta_box
  • 26. Meta Boxes • similarly to content types & taxonomies, there are GUI plugins to register meta boxes • More Fields: http://wordpress.org/ extend/plugins/more-fields/ • Advanced Custom Fields: http:// wordpress.org/extend/plugins/ advanced-custom-fields/ • Verve Meta Boxes: http:// wordpress.org/extend/plugins/verve- meta-boxes/
  • 27. Easier Meta Fields • Custom Metadata Manager by Mohammad Jangda • http://wordpress.org/extend/plugins/ custom-metadata/ • easy wrapper functions for adding meta boxes and custom fields
  • 28. Custom Metadata Manager x_add_metadata_field( $slug, $object_types = 'post', $args = array() ) x_add_metadata_group( $slug, $object_types = 'post', $args = array() )
  • 29. Even Further... • complex post to post (content to content) relations • allows web app functionality à la Rails/ Django • posts 2 posts plugin: http:// wordpress.org/extend/plugins/posts-to- posts/ • different page/content templates = different set of fields
  • 30. ✔ Lessons Learned • use custom content types for anything that isn’t a blog post and isn’t a static page • if you’re a developer, don’t rely on the database to register CPTs • if you’re not a developer, hire a developer, learn to code (copy/paste) or use a plugin • best way to learn = read the codex, code and make mistakes
  • 31. Extra links • Custom post type & custom taxonomy generator: http://themergency.com/ generators/ • Joachim’s WP.org profile page (the SLD helper class plugin will appear here once it’s live): http://profiles.wordpress.org/users/ jkudish • Colin’s WP.org profile page: http:// profiles.wordpress.org/users/cvernon • WordPress.tv (recorded presentation will appear here): http://wordpress.tv/
  • 33. Thanks! Any Questions? http://stresslim.it/welovewp @stresslimit / http://stresslimitdesign.com @jkudish / http://jkudish.com

Editor's Notes