Custom Post Types and Taxonomies
Upcoming SlideShare
Loading in...5
×
 

Custom Post Types and Taxonomies

on

  • 6,452 views

WordPress just got CMSier

WordPress just got CMSier

Statistics

Views

Total Views
6,452
Views on SlideShare
5,861
Embed Views
591

Actions

Likes
7
Downloads
61
Comments
1

9 Embeds 591

http://www.tammyhartdesigns.com 505
http://tammyhartdesigns.com 71
http://speakerrate.com 5
http://localhost 3
http://bird.tammyhartdesigns.com 2
http://www.linkedin.com 2
http://static.slidesharecdn.com 1
http://twitter.com 1
http://www.twylah.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • Thanks for sharing Tammy!
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Custom Post Types and Taxonomies Custom Post Types and Taxonomies Presentation Transcript

    • Custom Post Types & Taxonomies
      WordPress just got CMSier
    • Who Am I?
      I am a self-taught, freelance designer who has leveraged trial, error, and observation to become a WordPress expert.
      While I specialize in WordPress themes and CMS development, I also do all levels of Web Design and XHTML/CSS coding.
      I freelance some through my personal brand, Tammy Hart Designs, and I also work a full time gig at Infomediahere in Birmingham.
      TammyHartDesigns.com tammy@tammyhartdesigns.com @tammyhart
    • What is a Post Type?
      Posts, pages and more! Oh my!
    • How Does it Work?
      Content goes into the posts table
      Each content item is assigned a post_type
      Custom types are now easier to create and manage
    • Built in Types
      Main Content
      Post
      Page
      Other
      Attachment
      Revision
      Nav Menu Item
    • What Is a taxonomy?
      Read my lips, now new taxonomies
    • How Do They Work?
      Terms and their unique ID’s are saved in the terms table
      Terms are assigned a taxonomy in the term_taxonomy table
      Terms are related to posts (of all types) in the term_relationships table
    • Built in Taxonomies
      Post Taxonomies
      Category
      Post Tag
      Other
      Link Category
      Nav Menu
    • Hand Coding
      The hard way
    • Register a Post Type
      function post_type_movies(){
      register_post_type('movies',
      array('label'=> __('Movies'),
      'public'=>true,
      'show_ui'=>true,
      'supports' =>array(
      'post-thumbnails',
      'excerpts',
      'trackbacks',
      'custom-fields',
      'comments',
      'revisions')
      )
      );
      register_taxonomy_for_object_type('post_tag', 'movies');
      }
      add_action('init', 'post_type_movies');
      First Impressions of Custom Post Type by Frank Bültge on WPEngineer.org
      http://bit.ly/posttypes
    • Default Arguments
      // Args prefixed with an underscore are reserved for internal use.
      $defaults =array(
      'label' =>false,
      'publicly_queryable' => null,
      'exclude_from_search' => null,
      '_builtin' =>false,
      '_edit_link' =>'post.php?post=%d',
      'capability_type'=>'post',
      'hierarchical' => false,
      'public' => false,
      'rewrite' =>true,
      'query_var' =>true,
      'supports' =>array(),
      'register_meta_box_cb' => null,
      'taxonomies' =>array(),
      'show_ui' => null
      );
      First Impressions of Custom Post Type by Frank Bültge on WPEngineer.org
      http://bit.ly/posttypes
    • The Taxonomy Code
      function post_type_movies(){

      register_taxonomy('actor', 'movies',
      array(
      'hierarchical'=>true,
      'label'=> __('Actor')
      )
      );
      register_taxonomy(‘director', 'movies',
      array(
      'hierarchical'=>false,
      'label'=>__(‘Director'),
      'query_var'=>‘director',
      'rewrite' =>array('slug'=>‘director')
      )
      );
      }
      add_action('init', 'post_type_movies');
      First Impressions of Custom Post Type by Frank Bültge on WPEngineer.org
      http://bit.ly/posttypes
    • Using Plugins
      The easy way

    • Overheard
      WordCamp Birmingham 2009
      WordPress is the iPhone of the internet. You’ll always hear, “There’s a plugin for that!”
    • Plugins for Creating Them
      Custom Post Type UI
      Creates both
      TONS of labeling options
      WP Post Type UI
      Creates both
      Buggy
      Allows a custom icon
      More Types & More Taxonomies
      Allows you to override built in types and taxonomies
      Allows a custom icon
      Works seamlessly with the More Fields plugin (stay tuned for more)
    • Plugins for Manipulating Them
      Custom Post Type Order
      Drag and drop ordering
      Simple Custom Post Type Archives
      Adds support for custom post type archive permalinks
      Adds new body classes to custom post type archives
      Adds a new conditional, is_custom_post_type_archive
      Fixes the wp_title output on custom post type archives to show the custom type's label
      Adds custom post type feeds
      And more…
      Post Type Switcher
      Change the post type one item at a time
      Convert Post Types
      Bulk edit post types
    • Custom Templates
      Now what do I do?
    • Template Hierarchy
      Custom Post Type
      single-{post_type}.php
      single.php
      index.php
      Custom Taxonomy
      taxonomy-{taxonomy}-{term}.php
      taxonomy-{taxonomy}.php
      taxonomy.php
      archive.php
      index.php
    • Custom Loops & Queries
      This gets hardcore
    • The Loop
      The Basic Loop
      <?
      $loop =newWP_query('post_type=movies');
      while ($loop->have_posts()): $loop->the_post();
      ?>
      ... Do Stuff Here ...
      <?endwhile; ?>
      Add Custom Taxonomies
      $loop =newWP_query('post_type=movies&actor=joaquin-phoenix');
      $loop =newWP_query('post_type=movies&actor=joaquin-phoenix&director=m-night-shyamalan');
    • Term Lists
      Get All Terms
      $terms =get_terms('actors', 'order_by=count&order=DESC');
      Get Terms in a Post
      get_the_term_list( $post->ID, 'actors', '<p>Actors: ', ',', '</p>' )
      Other Functions
      get_term
      get_term_children
      get_term_by
      get_taxonomies
    • More Custom Content
      But wait, there’s more!

    • Matt Mullenweg
      WordCamp Birmingham 2009
      I like what you’re doing; I just don’t like the way you’re having to do it. So I’m going to make it better.
    • No More Flutter
      Custom Post Typesto create the special content
      Custom Taxonomiesto organize the content
      Custom Fieldsto get specific information on each post in a way that is human and pretty
    • Thanks!
      Questions?
      TammyHartDesigns.comtammy@tammyhartdesigns.com@tammyhart