Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Wp yeg post types talk


Published on

A short talk on Custom Post Types in Wordpress. Presented at the March 16 Wordpress Edmonton meetup at Startup Edmonton.

Get the companion plugin on my github here:

Published in: Software
  • Be the first to comment

  • Be the first to like this

Wp yeg post types talk

  1. 1. Custom Post Types What they are, and how to use them.
  2. 2. Who’s this guy? ● Stephen Brown ● Graduated from DMIT at NAIT ● Web Developer at AgileStyle ( ● Primarily work with Wordpress and Front-End languages. ● Dipping my toes into Ruby and Ruby on Rails
  3. 3. Before we begin! Thank You! I made a plugin!
  4. 4. Why Custom Post Types? ● Was semi-volunteered... ● Most of us use them, and have probably used a generator of one kind or another. But what are they really? It’s your job as a developer to understand the code you are using, especially if you didn’t write it.
  5. 5. Post types trivia ● First introduced in 2005 with Wordpress 1.5 when ‘pages’ were added. ● register_post_type() - the focus of this talk - was added to core in Wordpress 3.0 ● Much of Wordpress’ core content is made of distinct post types: o Posts, Pages, Attachments, Revisions, and Navigation Menus
  6. 6. Why use them? ● They help you get past limitations of the default types (eventually). ● Custom Post Types allow you to determine your own dynamic content types. ● Let you avoid fumbling with html structure in your post content. Post types are a part of what makes Wordpress so flexible
  7. 7. From the codex: $post_type: (string) The handle for the post type. - No capitals letters or spaces $args: (array) The options for the post type. - Reference ‘post_types.php’ in the plugin for these options. Down to business! register_post_type( $post_type, $args );
  8. 8. List of all posts of this post type: (Assuming ‘publicly_queryable’ is true) Go to single post: Template Files: Archive - archive-post_type.php Single Post - single-post_type.php Now what? if rewriting set if rewriting set
  9. 9. The next step Unfortunately, this is only part of the custom content puzzle. Still need: ● Custom Fields ● Custom Taxonomies Resources Smashing Magazine - Guide to CPTs BetterWP - Custom Post Types Explained Themergency - Post Type Generator Wordpress Codex - register_post_type()
  10. 10. Questions?