creatively creating custom post types!
DESCRIPTION
TRANSCRIPT
![Page 1: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/1.jpg)
Creatively Creating Custom Post TypesNikhil Vimal #WordUpMPLS
![Page 2: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/2.jpg)
Hi, I’m Nikhil
• I develop with WordPress• I can be found on Twitter @TechVoltz• This my first talk ever
![Page 3: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/3.jpg)
Custom Post Types?They Rock (Seriously)
![Page 4: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/4.jpg)
But what are they?
• Instead of using default posts and categories in WordPress, use Custom Post Types
•You can add a lot of cool things that are not in a Default WordPress install
•Added in WordPress 3.0
![Page 5: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/5.jpg)
Why Do You need them?Organization
![Page 6: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/6.jpg)
PortfolioPost Type could be paintings
![Page 7: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/7.jpg)
Online StorePost Type could be Products
![Page 8: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/8.jpg)
Your only limitation isYour imagination
![Page 9: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/9.jpg)
“WordPress can hold and display many different types of content.”
-WordPress Codex
![Page 10: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/10.jpg)
But how do we add Custom Post Types?With a plugin of course
![Page 11: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/11.jpg)
Create a file called myposttype.php<?php/** * Plugin Name: Your Custom Post Type * Plugin URI: http://yourpluginswebsite.com * Description: A brief description of your Plugin. * Version: The Plugin's Version Number, e.g.: 1.0 * Author: Your Name * Author URI: http://yourwebsite.com * License: A "Slug" license name e.g. GPL2 */
![Page 12: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/12.jpg)
add_action('init', 'wordup_sessions');
function wordup_sessions() { $wordup_args = array( 'public' => true, 'has_archive' => true, 'query_var' => 'wordup', 'menu_position' => 5, 'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ), 'labels' => array( 'name' => 'WordUp Sessions', 'singular' => 'WordUp Session', 'add_new' => 'Add Session', 'add_new_item' => 'Add Session', 'edit_item' => 'Edit Session', 'new_item' => 'New Session', 'view_item' => 'View Session', 'search_items' => 'Search WordUp', 'not_found' => 'No sessions found', 'not_found_in_trash' => 'No Sessions found in the Trash', ), ); register_post_type('WordUp', $wordup_args ); }
![Page 13: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/13.jpg)
Lets examine all the code!!
![Page 14: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/14.jpg)
add_action('init', 'wordup_sessions');
![Page 15: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/15.jpg)
function wordup_sessions() { $wordup_args = array( 'public' => true, 'has_archive' => true, 'query_var' => 'wordup', 'menu_position' => 5, 'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ),
![Page 16: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/16.jpg)
'labels' => array( 'name' => 'WordUp Sessions', 'singular' => 'WordUp Session', 'add_new' => 'Add Session', 'add_new_item' => 'Add Session', 'edit_item' => 'Edit Session', 'new_item' => 'New Session', 'view_item' => 'View Session', 'search_items' => 'Search Sessions', 'not_found' => 'No sessions found', 'not_found_in_trash' => 'No Sessions found in the Trash', ),);
![Page 17: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/17.jpg)
register_post_type('WordUp', $wordup_args ); }
![Page 18: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/18.jpg)
Styling your CPT PageWith single-$posttype.php
![Page 19: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/19.jpg)
Having an Archive Page for your CPTWith archive-$posttype.php
![Page 20: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/20.jpg)
![Page 21: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/21.jpg)
![Page 22: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/22.jpg)
![Page 23: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/23.jpg)
TaxonomiesMore Organization
![Page 24: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/24.jpg)
“Basically, a taxonomy is a way to group things together”
-WordPress Codex
![Page 25: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/25.jpg)
TaxonomiesCategories and Tags
![Page 26: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/26.jpg)
PortfolioTaxonomy is oil painting
![Page 27: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/27.jpg)
After our Custom Post type function….
![Page 28: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/28.jpg)
add_action('init', 'wordup_tracks');
![Page 29: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/29.jpg)
function wordup_tracks(){ $track_args = array( 'hierarchical' => true, 'query_var' => ‘wordup_tracks', 'show_tagcloud' => true,
![Page 30: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/30.jpg)
'labels' => array( 'name' => 'Tracks', 'edit_item' => 'Edit Track', 'update_item' => 'Update Track', 'add_new_item' => 'Add New Track', 'new_item_name' => 'New Track', 'all_items' => 'All Tracks', 'search_items' => 'Search Tracks', 'popular_items' => 'Popular Tracks', 'add_or_remove_items' => 'Add or remove Tracks', 'choose_from_most_used' => 'Choose from most used Tracks', ), );
![Page 31: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/31.jpg)
register_taxonomy(‘wordup_tracks', array('wordup'), $dev_args);
}
The array(‘wordup’) is our custom post type
![Page 32: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/32.jpg)
![Page 33: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/33.jpg)
You can add moreLike Custom Fields
![Page 34: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/34.jpg)
Questions?
![Page 35: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/35.jpg)
Resources• http://
justintadlock.com/archives/2010/04/29/custom-post-types-in-wordpress• http://codex.wordpress.org/Post_Types• http://codex.wordpress.org/Taxonomies• http
://wp.smashingmagazine.com/2012/11/08/complete-guide-custom-post-types/
![Page 36: Creatively creating custom post types!](https://reader035.vdocuments.mx/reader035/viewer/2022070303/54b436aa4a7959586c8b45dd/html5/thumbnails/36.jpg)
Thank You!Nikhil Vimal@TechVoltz