SlideShare a Scribd company logo
Custom Post Types and Taxonomies In WordPress Brad Williams WebDevStudios.com
Who Am I?
Brad Williams Co-Founder of WebDevStudios.com Organizer NJ WordPress Meetup Co-Host SitePoint Podcast Co-Author of  Professional WordPress  (http://bit.ly/pro-wp) Who Am I?
Explain Custom Post Types and Taxonomies Create Custom Post Types Create Custom Taxonomies Hooking into WordPress Topics
So what are  Custom Post Types?
So what are  Custom Post Types? CODEX : Post type refers to the various structured data that is maintained in the WordPress posts table. Native (or built-in) post type are  post ,  page ,  attachment ,  revision , and  nav-menu-item . Custom post types are also supported in WordPress and can be defined with  register_post_type() .
WTFrack?
So what are  Custom Post Types Really? ENGLISH : Custom Post Types allow you to create different types of content in WordPress.
Default WordPress Post Types: Posts Pages Attachments Revisions Nav Menus (WP 3.0)
Custom Post Type Ideas Podcasts Movies Bars Forum Quotes Videos Cars House Listings Events Ticket System etc, etc, etc The possibilities are endless!
Example Time! Tweet: @williamsba CAUTION ZOMBIES AHEAD! #wcraleigh Win a copy of Professional WordPress!
Example: Zombie Modeling Agency
Example: Zombie Modeling Agency <?php add_action( 'init', 'create_zombie_post_type' ); function create_zombie_post_type() { register_post_type('zombies',  array( 'label' => 'Zombies', 'public' => true, )  ); } ?> Drop the below code in your themes functions.php file
Example: Zombie Modeling Agency Drop the below code in your themes functions.php file
Example: Zombie Modeling Agency <?php add_action( 'init', 'create_zombie_post_type' ); function create_zombie_post_type() { register_post_type('zombies',  array( 'label' => 'Zombies', 'public' => true, )  ); } ?> Lets break it down: 1. Action hook to trigger our function 2. Execute the register_post_type function defining zombies as our custom post type 3. Set the label  to Zombies 4. Set public to true.  By default public is false which will hide your post type
Additional Arguments:  labels An array of strings that represent your post type in the WP admin name: The plural form of the name of your post type. singular_name: The singular form of the name of your post type. add_new: The menu item for adding a new post. add_new_item: The header shown when creating a new post. edit: The menu item for editing posts. edit_item: The header shown when editing a post. new_item: Shown in the favorites menu in the admin header. view: Used as text in a link to view the post. view_item: Shown alongside the permalink on the edit post screen. search_items: Button text for the search box on the edit posts screen. not_found: Text to display when no posts are found through search in the admin. not_found_in_trash: Text to display when no posts are in the trash. parent: Used as a label for a parent post on the edit posts screen. Only useful for hierarchical post types. Ref: http://justintadlock.com/archives/2010/04/29/custom-post-types-in-wordpress
Additional Arguments:  labels register_post_type('zombies',  array( 'labels' => array( 'name' => 'Zombies', 'singular_name' => 'Zombie', 'add_new' => 'Add New Zombie', 'add_new_item' => 'Add New Zombie', 'edit' => 'Edit Zombies', 'edit_item' => 'Edit Zombie', 'new_item' => 'New Zombie', 'view' => 'View Zombie', 'view_item' => 'View Zombie', 'search_items' => 'Search Zombies', 'not_found' => 'No zombies found', 'not_found_in_trash' => 'No zombies found in Trash', 'parent' => 'Parent Zombie', ), 'public' => true, )  ); An array of strings that represent your post type in the WP admin
Additional Arguments:  labels The Result
Additional Arguments:  supports Defines what meta boxes and other fields appear on the edit screen title: Text input field for the post title. editor: Main content meta box comments: Ability to turn comments on/off. trackbacks: Ability to turn trackbacks and pingbacks on/off. revisions: Allows revisions to be made of your post. author: Displays the post author select box. excerpt: A textarea for writing a custom excerpt. thumbnail: The post thumbnail (featured imaged) upload box. custom-fields: Custom fields input area. page-attributes: The attributes box shown for pages. Important for hierarchical post types, so you can select the parent post.
Additional Arguments:  supports Defines what meta boxes and other fields appear on the edit screen register_post_type('zombies',  array( 'labels' => array( 'name' => 'Zombies', 'singular_name' => 'Zombie', 'add_new' => 'Add New Zombie', 'add_new_item' => 'Add New Zombie', 'edit' => 'Edit Zombies', 'edit_item' => 'Edit Zombie', 'new_item' => 'New Zombie', 'view' => 'View Zombie', 'view_item' => 'View Zombie', 'search_items' => 'Search Zombies', 'not_found' => 'No zombies found', 'not_found_in_trash' => 'No zombies found in Trash', 'parent' => 'Parent Zombie', ), 'supports' => array('title'), 'public' => true, )  );
Additional Arguments:  supports Defines what meta boxes and other fields appear on the edit screen Only the Title and Publish meta boxes are displayed
Additional Arguments:  supports Now lets activate all meta boxes register_post_type('zombies',  array( 'labels' => array( 'name' => 'Zombies', 'singular_name' => 'Zombie', 'add_new' => 'Add New Zombie', 'add_new_item' => 'Add New Zombie', 'edit' => 'Edit Zombies', 'edit_item' => 'Edit Zombie', 'new_item' => 'New Zombie', 'view' => 'View Zombie', 'view_item' => 'View Zombie', 'search_items' => 'Search Zombies', 'not_found' => 'No zombies found', 'not_found_in_trash' => 'No zombies found in Trash', 'parent' => 'Parent Zombie', ), 'supports' => array('title‘,'editor‘,'excerpt‘, 'trackbacks‘,'custom-fields', 'comments‘,'revisions‘,'thumbnail‘,'author‘,'page-attributes'), 'public' => true, )  );
Additional Arguments:  supports Now all meta boxes are displayed on the Zombie edit screen
Additional Arguments:  rewrite Defines the permalink structure of your custom post type posts slug: The slug to use in your permalink structure with_front: whether your post type should use the front base from your permalink settings (eg /blog) 'rewrite' => array('slug' => 'zombie') Example: BEFORE AFTER
Additional Arguments:  taxonomies Add preexisting taxonomies to your custom post type 'taxonomies' => array( 'post_tag', 'category') Example:
Additional Arguments:  misc Below are additional arguments for creating custom post types hierarchical: whether the post type is hierarchical description: a text description of your custom post type show_ui: whether to show the admin menus/screens menu_position: Set the position of the menu order where the post type should appear menu_icon: URL to the menu icon to be used exclude_from_search: whether post type content should appear in search results
Putting it all together register_post_type('zombies',  array( 'description' => 'Zombie custom post type', 'show_ui' => true, 'menu_position' => 5, 'menu_icon' => get_stylesheet_directory_uri() . '/images/zombies.png', 'exclude_from_search' => false, 'labels' => array( 'name' => 'Zombies', 'singular_name' => 'Zombie', 'add_new' => 'Add New Zombie', 'add_new_item' => 'Add New Zombie', 'edit' => 'Edit Zombies', 'edit_item' => 'Edit Zombie', 'new_item' => 'New Zombie', 'view' => 'View Zombie', 'view_item' => 'View Zombie', 'search_items' => 'Search Zombies', 'not_found' => 'No zombies found', 'not_found_in_trash' => 'No zombies found in Trash', 'parent' => 'Parent Zombie', ), 'supports' => array('title','editor','excerpt', 'trackbacks','custom-fields', 'comments','revisions','thumbnail','author','page-attributes'), 'public' => true, 'rewrite' => array('slug' => 'zombie', 'with_front' => false), 'taxonomies' => array( 'post_tag', 'category') )  );
So what are Taxonomies?
So what are Taxonomies? ENGLISH : Taxonomies are a way to group similar items together
Default WordPress Taxonomies: Category Tag Link Category
Example Time! Tweet: @williamsba ZOMBIES IN AREA! RUN #wcraleigh Win a copy of Professional WordPress!
Example: Zombie Modeling Agency <?php add_action( 'init', 'create_zombie_taxonomies' ); function create_zombie_taxonomies() { register_taxonomy( 'freshness', 'zombies', array( 'hierarchical' => false, 'label' => 'Freshness' ) ); } ?> Drop the below code in your themes functions.php file Non-hierarchical Taxonomy
Example: Zombie Modeling Agency New custom taxonomy is automatically added to the Zombies post type menu The Freshness meta box is also automatically added to the Zombie edit screen automatically!
Example: Zombie Modeling Agency <?php add_action( 'init', 'create_zombie_taxonomies' ); function create_zombie_taxonomies() { register_taxonomy( 'freshness', 'zombies', array( 'hierarchical' => true, 'label' => 'Freshness' ) ); } ?> Drop the below code in your themes functions.php file Hierarchical Taxonomy
Example: Zombie Modeling Agency New custom taxonomy is automatically added to the Zombies post type menu The Freshness meta box is also automatically added to the Zombie edit screen automatically!
Example: Zombie Modeling Agency Lets break it down: Action hook to trigger our function Execute the register_taxonomy function defining freshness as our custom taxonomy Set the name to freshness Set the object type to ‘zombies’.  Must be an existing post type Set hierarchical to false Set our taxonomy label to Freshness <?php add_action( 'init', 'create_zombie_taxonomies' ); function create_zombie_taxonomies() { register_taxonomy(  'freshness', 'zombies',  array(  'hierarchical' => false,  'label' => 'Freshness'  )  ); } ?>
Additional Arguments: labels An array of strings that represent your taxonomy in the WP admin name: The general name of your taxonomy singular_name: The singular form of the name of your taxonomy. search_items: The search items text popular_items: The popular items text all_items: The all items text parent_item: The parent item text.  Only used on hierarchical taxonomies parent_item_colon: Same as parent_item, but with a colon edit_item: The edit item text update_item: The update item text add_new_item: The add new item text new_item_name: The new item name text
Additional Arguments: labels register_taxonomy(  'freshness',  'zombies', array(  'labels' => array( 'name' => 'Freshness', 'singular_name' => 'Freshness', 'search_items' =>  'Search Freshness', 'popular_items' => 'Popular Freshness', 'all_items' => 'All Freshness', 'parent_item' => 'Parent Freshness', 'parent_item_colon' => 'Parent Freshness:', 'edit_item' => 'Edit Freshness',  'update_item' => 'Update Freshness', 'add_new_item' => 'Add New Freshness', 'new_item_name' => 'New Freshness Name' ),  'hierarchical' => false,  'label' => 'Freshness' )  ); An array of strings that represent your taxonomy in the WP admin
Additional Arguments: labels The Result
Additional Arguments: rewrite Defines the permalink structure for your custom taxonomy slug: The slug to use in your permalink structure with_front: whether your taxonomy should use the front base from your permalink settings (eg /blog) 'rewrite' => array('slug' => fresh') Example: BEFORE AFTER http://x.webdevstudios.com/blog/freshness/ripe/ http://x.webdevstudios.com/blog/fresh/ripe/
Additional Arguments: misc Below are additional arguments for creating custom taxonomies public: whether the taxonomy is publicly queryable show_ui: whether to display the admin UI for the taxonomy hierarchical: whether the taxonomy is hierarchical.  Categories are hierarchical, tags are not. label: the name of your taxonomy in the admin dashboard query_var: whether to be able to query posts using the taxonomy.  rewrite: whether to use a pretty permalink when viewing the taxonomy page. show_tagcloud: whether to show a tag cloud in the admin UI
Putting it all together register_taxonomy(  'freshness',  'zombies', array(  'labels' => array( 'name' => 'Freshness', 'singular_name' => 'Freshness', 'search_items' =>  'Search Freshness', 'popular_items' => 'Popular Freshness', 'all_items' => 'All Freshness', 'parent_item' => 'Parent Freshness', 'parent_item_colon' => 'Parent Freshness:', 'edit_item' => 'Edit Freshness',  'update_item' => 'Update Freshness', 'add_new_item' => 'Add New Freshness', 'new_item_name' => 'New Freshness Name' ),  'hierarchical' => false,  'public' => true, 'show_ui' => true, 'query_var' => 'freshness', 'show_tagcloud' => true, 'rewrite' => array( 'slug' => 'fresh', 'with_front' => false )  )  );
 
Displaying in WordPress  #protip
Displaying Custom Post Type Content <?php query_posts( array( 'post_type' => 'zombies' ) ); ?> By default custom post type content will NOT display in the Loop Placing the above code directly before the Loop will only display our zombies
Displaying Custom Post Type Content <?php query_posts( array( 'post_type' => 'zombies' ) ); ?> BEFORE ZOMBIED (After)
Custom Loop <?php  $zombies = new WP_Query( array( 'post_type' => 'zombies', 'posts_per_page' => 1, 'orderby' => 'rand' ) ); while ( $zombies->have_posts() ) : $zombies->the_post(); the_title( '<h2><a href=&quot;' . get_permalink() . '&quot; >', '</a></h2>' ); ?> <div class=&quot;entry-content&quot;> <?php the_content(); ?> </div> <?php endwhile; ?> Creating a custom Loop for your post type
<?php  if (have_posts()) : while (have_posts()) : the_post();  $post_type = get_post_type( get_the_ID() ); if ($post_type == 'zombies') { echo 'This is a Zombie!'; } ?> <?php endwhile; ?> <?php endif; ?> Function: get_post_type() Returns the post type of the content you are viewing Custom Post Type Functions http://codex.wordpress.org/Function_Reference/get_post_type
if ( is_post_type( 'zombies' ) ) { echo 'Zombies Exist!'; } Function: is_post_type() Check if a post type exists Custom Post Type Functions if ( is_post_type( 'zombies' $post_id) ) { echo ‘Post ID: ‘ .$post_id .‘is a Zombie!'; } Can also check a specific post against a post type
<?php echo get_the_term_list( $post->ID, 'freshness', 'Freshness: ', ', ', '' ); ?> Function: get_the_term_list() Display freshness taxonomy for our zombies Custom Taxonomy Functions http://codex.wordpress.org/Function_Reference/get_the_term_list
Recommended Plugin
Custom Post Type UI http://wordpress.org/extend/plugins/custom-post-type-ui/ Easily create custom post types without writing code!
Custom Post Type UI http://wordpress.org/extend/plugins/custom-post-type-ui/ Also easily create custom taxonomies without writing code!
Custom Post Type UI http://wordpress.org/extend/plugins/custom-post-type-ui/ Plugin also gives you the PHP code for custom post types and taxonomies!
Related Codex Articles http://codex.wordpress.org/Hardening_WordPress Custom Post Type Articles http://justintadlock.com/archives/2010/04/29/custom-post-types-in-wordpress http://justintadlock.com/archives/2010/02/02/showing-custom-post-types-on-your-home-blog-page http://kovshenin.com/archives/custom-post-types-in-wordpress-3-0/ http://wpengineer.com/impressions-of-custom-post-type/ Custom Taxonomies http://justintadlock.com/archives/2009/05/06/custom-taxonomies-in-wordpress-28 http://justintadlock.com/archives/2009/06/04/using-custom-taxonomies-to-create-a-movie-database http://www.shibashake.com/wordpress-theme/wordpress-custom-taxonomy-input-panels Custom Post Type and Taxonomy Resources
Brad Williams [email_address] Blog: strangework.com Twitter: @williamsba IRC: WDS-Brad Contact Professional WordPress: http://bit.ly/pro-wp

More Related Content

What's hot

Creating Customizable Widgets for Unpredictable Needs
Creating Customizable Widgets for Unpredictable NeedsCreating Customizable Widgets for Unpredictable Needs
Creating Customizable Widgets for Unpredictable Needs
Amanda Giles
 
Custom content types &amp; custom taxonomies in wordpress
Custom content types &amp; custom taxonomies in wordpressCustom content types &amp; custom taxonomies in wordpress
Custom content types &amp; custom taxonomies in wordpress
stimasoft
 
WordCamp Kent 2019 - WP 101: Custom Post Type & Custom Fields
WordCamp Kent 2019 - WP 101: Custom Post Type & Custom FieldsWordCamp Kent 2019 - WP 101: Custom Post Type & Custom Fields
WordCamp Kent 2019 - WP 101: Custom Post Type & Custom Fields
Joe Querin
 
Wp meetup custom post types
Wp meetup custom post typesWp meetup custom post types
Wp meetup custom post types
Morten Rand-Hendriksen
 
Custom WordPress theme development
Custom WordPress theme developmentCustom WordPress theme development
Custom WordPress theme development
Tammy Hart
 
Introduction to WordPress Theme Development
Introduction to WordPress Theme DevelopmentIntroduction to WordPress Theme Development
Introduction to WordPress Theme Development
Sitdhibong Laokok
 
WordPress theme development from scratch : ICT MeetUp 2013 Nepal
WordPress theme development from scratch : ICT MeetUp 2013 NepalWordPress theme development from scratch : ICT MeetUp 2013 Nepal
WordPress theme development from scratch : ICT MeetUp 2013 Nepal
Chandra Prakash Thapa
 
Wordcamp St. Louis - Clean Coding
Wordcamp St. Louis - Clean CodingWordcamp St. Louis - Clean Coding
Wordcamp St. Louis - Clean Coding
inspector_fegter
 
Introduction to Custom WordPress Themeing
Introduction to Custom WordPress ThemeingIntroduction to Custom WordPress Themeing
Introduction to Custom WordPress Themeing
Jamie Schmid
 
Ingo Muschenetz: Titanium Studio Deep Dive
Ingo Muschenetz: Titanium Studio Deep DiveIngo Muschenetz: Titanium Studio Deep Dive
Ingo Muschenetz: Titanium Studio Deep Dive
Axway Appcelerator
 
WordPress Theme Development
 WordPress Theme Development WordPress Theme Development
WordPress Theme Development
Bijay Oli
 
WordPress Theme Structure
WordPress Theme StructureWordPress Theme Structure
WordPress Theme Structure
keithdevon
 
The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017
Amanda Giles
 
Bending word press to your will
Bending word press to your willBending word press to your will
Bending word press to your will
Tom Jenkins
 
Accomplish It With Core: Sliders, Galleries and More
Accomplish It With Core: Sliders, Galleries and MoreAccomplish It With Core: Sliders, Galleries and More
Accomplish It With Core: Sliders, Galleries and More
Andy Stratton
 
Accomplish It With Core: Sliders Galleries + More
Accomplish It With Core: Sliders Galleries + MoreAccomplish It With Core: Sliders Galleries + More
Accomplish It With Core: Sliders Galleries + More
Andy Stratton
 
WordPress Theme Development
WordPress Theme DevelopmentWordPress Theme Development
WordPress Theme Development
WisdmLabs
 
Turbo charged WordPress theme development - WordCamp Edinburgh 2012
Turbo charged WordPress theme development - WordCamp Edinburgh 2012Turbo charged WordPress theme development - WordCamp Edinburgh 2012
Turbo charged WordPress theme development - WordCamp Edinburgh 2012
Jonny Allbut
 
An Introduction to Custom Post Types
An Introduction to Custom Post TypesAn Introduction to Custom Post Types
An Introduction to Custom Post Types
Carleton Web Services
 
Joomla! Day Chicago 2011 - Templating the right way - Jonathan Shroyer
Joomla! Day Chicago 2011 - Templating the right way - Jonathan ShroyerJoomla! Day Chicago 2011 - Templating the right way - Jonathan Shroyer
Joomla! Day Chicago 2011 - Templating the right way - Jonathan Shroyer
Steven Pignataro
 

What's hot (20)

Creating Customizable Widgets for Unpredictable Needs
Creating Customizable Widgets for Unpredictable NeedsCreating Customizable Widgets for Unpredictable Needs
Creating Customizable Widgets for Unpredictable Needs
 
Custom content types &amp; custom taxonomies in wordpress
Custom content types &amp; custom taxonomies in wordpressCustom content types &amp; custom taxonomies in wordpress
Custom content types &amp; custom taxonomies in wordpress
 
WordCamp Kent 2019 - WP 101: Custom Post Type & Custom Fields
WordCamp Kent 2019 - WP 101: Custom Post Type & Custom FieldsWordCamp Kent 2019 - WP 101: Custom Post Type & Custom Fields
WordCamp Kent 2019 - WP 101: Custom Post Type & Custom Fields
 
Wp meetup custom post types
Wp meetup custom post typesWp meetup custom post types
Wp meetup custom post types
 
Custom WordPress theme development
Custom WordPress theme developmentCustom WordPress theme development
Custom WordPress theme development
 
Introduction to WordPress Theme Development
Introduction to WordPress Theme DevelopmentIntroduction to WordPress Theme Development
Introduction to WordPress Theme Development
 
WordPress theme development from scratch : ICT MeetUp 2013 Nepal
WordPress theme development from scratch : ICT MeetUp 2013 NepalWordPress theme development from scratch : ICT MeetUp 2013 Nepal
WordPress theme development from scratch : ICT MeetUp 2013 Nepal
 
Wordcamp St. Louis - Clean Coding
Wordcamp St. Louis - Clean CodingWordcamp St. Louis - Clean Coding
Wordcamp St. Louis - Clean Coding
 
Introduction to Custom WordPress Themeing
Introduction to Custom WordPress ThemeingIntroduction to Custom WordPress Themeing
Introduction to Custom WordPress Themeing
 
Ingo Muschenetz: Titanium Studio Deep Dive
Ingo Muschenetz: Titanium Studio Deep DiveIngo Muschenetz: Titanium Studio Deep Dive
Ingo Muschenetz: Titanium Studio Deep Dive
 
WordPress Theme Development
 WordPress Theme Development WordPress Theme Development
WordPress Theme Development
 
WordPress Theme Structure
WordPress Theme StructureWordPress Theme Structure
WordPress Theme Structure
 
The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017
 
Bending word press to your will
Bending word press to your willBending word press to your will
Bending word press to your will
 
Accomplish It With Core: Sliders, Galleries and More
Accomplish It With Core: Sliders, Galleries and MoreAccomplish It With Core: Sliders, Galleries and More
Accomplish It With Core: Sliders, Galleries and More
 
Accomplish It With Core: Sliders Galleries + More
Accomplish It With Core: Sliders Galleries + MoreAccomplish It With Core: Sliders Galleries + More
Accomplish It With Core: Sliders Galleries + More
 
WordPress Theme Development
WordPress Theme DevelopmentWordPress Theme Development
WordPress Theme Development
 
Turbo charged WordPress theme development - WordCamp Edinburgh 2012
Turbo charged WordPress theme development - WordCamp Edinburgh 2012Turbo charged WordPress theme development - WordCamp Edinburgh 2012
Turbo charged WordPress theme development - WordCamp Edinburgh 2012
 
An Introduction to Custom Post Types
An Introduction to Custom Post TypesAn Introduction to Custom Post Types
An Introduction to Custom Post Types
 
Joomla! Day Chicago 2011 - Templating the right way - Jonathan Shroyer
Joomla! Day Chicago 2011 - Templating the right way - Jonathan ShroyerJoomla! Day Chicago 2011 - Templating the right way - Jonathan Shroyer
Joomla! Day Chicago 2011 - Templating the right way - Jonathan Shroyer
 

Viewers also liked

QUIERO SER DIRECTOR DE CINE
QUIERO SER DIRECTOR DE CINEQUIERO SER DIRECTOR DE CINE
QUIERO SER DIRECTOR DE CINE
José Salvador Fraile Infantes
 
Haciendo cine
Haciendo cineHaciendo cine
Haciendo cine
TEAMRENTERIA
 
Presentación1
Presentación1Presentación1
Presentación1
natiskri
 
Presentación3
Presentación3Presentación3
Presentación3
paoliiiiiiiiiiiii
 
Using SASS in the WordPress environment - Ran Bar Zik
Using SASS in the WordPress environment - Ran Bar ZikUsing SASS in the WordPress environment - Ran Bar Zik
Using SASS in the WordPress environment - Ran Bar Zik
Miriam Schwab
 
El Guión
El GuiónEl Guión
El Guión
Cinefilos
 
Mi proyecto
Mi proyectoMi proyecto
Mi proyecto
Mina Ahmed Ali
 
Ciclo De Cine Infantil
Ciclo De Cine InfantilCiclo De Cine Infantil
Ciclo De Cine Infantil
guest2ba6fa2
 
Cine infantil
Cine infantilCine infantil
Cine infantil
daisy.caspa
 
Imagen en movimiento
Imagen en movimientoImagen en movimiento
Imagen en movimiento
pixelfx
 
Proyecto cine
Proyecto cineProyecto cine
Proyecto cine
Salomar83
 
Infancia y cine después de 1983 en Argentina
Infancia y cine después de 1983 en ArgentinaInfancia y cine después de 1983 en Argentina
Infancia y cine después de 1983 en Argentina
Patricia Gagliardi
 
Web quest2
Web quest2Web quest2
Web quest2
BILBIAUGUSTA
 
CINE DE ANIMACIÓN
CINE DE ANIMACIÓNCINE DE ANIMACIÓN
CINE DE ANIMACIÓN
David Nuñez
 
Producción Audiovisual Cine: Tema3
Producción Audiovisual Cine: Tema3Producción Audiovisual Cine: Tema3
Producción Audiovisual Cine: Tema3
Rafael Linares Palomar
 
Aprendemos con el cine
Aprendemos con el cineAprendemos con el cine
Aprendemos con el cine
Salomar83
 
Pre producción
Pre producciónPre producción
Pre producción
Johana Vera
 
Taller de cine por Patricia Cabrejas
Taller de cine por Patricia CabrejasTaller de cine por Patricia Cabrejas
Taller de cine por Patricia Cabrejas
patisukiya
 
Cine Infantil
Cine InfantilCine Infantil
Cine Infantil
cm_caromanrique
 
Web quest1
Web quest1Web quest1
Web quest1
BILBIAUGUSTA
 

Viewers also liked (20)

QUIERO SER DIRECTOR DE CINE
QUIERO SER DIRECTOR DE CINEQUIERO SER DIRECTOR DE CINE
QUIERO SER DIRECTOR DE CINE
 
Haciendo cine
Haciendo cineHaciendo cine
Haciendo cine
 
Presentación1
Presentación1Presentación1
Presentación1
 
Presentación3
Presentación3Presentación3
Presentación3
 
Using SASS in the WordPress environment - Ran Bar Zik
Using SASS in the WordPress environment - Ran Bar ZikUsing SASS in the WordPress environment - Ran Bar Zik
Using SASS in the WordPress environment - Ran Bar Zik
 
El Guión
El GuiónEl Guión
El Guión
 
Mi proyecto
Mi proyectoMi proyecto
Mi proyecto
 
Ciclo De Cine Infantil
Ciclo De Cine InfantilCiclo De Cine Infantil
Ciclo De Cine Infantil
 
Cine infantil
Cine infantilCine infantil
Cine infantil
 
Imagen en movimiento
Imagen en movimientoImagen en movimiento
Imagen en movimiento
 
Proyecto cine
Proyecto cineProyecto cine
Proyecto cine
 
Infancia y cine después de 1983 en Argentina
Infancia y cine después de 1983 en ArgentinaInfancia y cine después de 1983 en Argentina
Infancia y cine después de 1983 en Argentina
 
Web quest2
Web quest2Web quest2
Web quest2
 
CINE DE ANIMACIÓN
CINE DE ANIMACIÓNCINE DE ANIMACIÓN
CINE DE ANIMACIÓN
 
Producción Audiovisual Cine: Tema3
Producción Audiovisual Cine: Tema3Producción Audiovisual Cine: Tema3
Producción Audiovisual Cine: Tema3
 
Aprendemos con el cine
Aprendemos con el cineAprendemos con el cine
Aprendemos con el cine
 
Pre producción
Pre producciónPre producción
Pre producción
 
Taller de cine por Patricia Cabrejas
Taller de cine por Patricia CabrejasTaller de cine por Patricia Cabrejas
Taller de cine por Patricia Cabrejas
 
Cine Infantil
Cine InfantilCine Infantil
Cine Infantil
 
Web quest1
Web quest1Web quest1
Web quest1
 

Similar to Custom Post Types and Taxonomies in WordPress

Surviving the Zombie Apocalypse using Custom Post Types and Taxonomies
Surviving the Zombie Apocalypse using Custom Post Types and TaxonomiesSurviving the Zombie Apocalypse using Custom Post Types and Taxonomies
Surviving the Zombie Apocalypse using Custom Post Types and Taxonomies
Brad Williams
 
WordCamp Detroit 2010 Wordpress Theme Hacks
WordCamp Detroit 2010 Wordpress Theme HacksWordCamp Detroit 2010 Wordpress Theme Hacks
WordCamp Detroit 2010 Wordpress Theme Hacks
John Pratt
 
WordPress development paradigms, idiosyncrasies and other big words
WordPress development paradigms, idiosyncrasies and other big wordsWordPress development paradigms, idiosyncrasies and other big words
WordPress development paradigms, idiosyncrasies and other big words
TomAuger
 
Sencha Touch Intro
Sencha Touch IntroSencha Touch Intro
Sencha Touch Intro
Shea Frederick
 
How To Write a WordPress Plugin
How To Write a WordPress PluginHow To Write a WordPress Plugin
How To Write a WordPress Plugin
Andy Stratton
 
WordPress as a Content Management System
WordPress as a Content Management SystemWordPress as a Content Management System
WordPress as a Content Management System
Valent Mustamin
 
Abstracting functionality with centralised content
Abstracting functionality with centralised contentAbstracting functionality with centralised content
Abstracting functionality with centralised content
Michael Peacock
 
Moose (Perl 5)
Moose (Perl 5)Moose (Perl 5)
Moose (Perl 5)
xSawyer
 
Moose talk at FOSDEM 2011 (Perl devroom)
Moose talk at FOSDEM 2011 (Perl devroom)Moose talk at FOSDEM 2011 (Perl devroom)
Moose talk at FOSDEM 2011 (Perl devroom)
xSawyer
 
Widgets: Making Your Site Great and Letting Others Help - WordCamp Victoria
Widgets: Making Your Site Great and Letting Others Help - WordCamp VictoriaWidgets: Making Your Site Great and Letting Others Help - WordCamp Victoria
Widgets: Making Your Site Great and Letting Others Help - WordCamp Victoria
Jeff Richards
 
Creatively creating custom post types! word sesh2
Creatively creating custom post types!  word sesh2Creatively creating custom post types!  word sesh2
Creatively creating custom post types! word sesh2
techvoltz
 
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
namlook
 
WordPress Development Confoo 2010
WordPress Development Confoo 2010WordPress Development Confoo 2010
WordPress Development Confoo 2010
Brendan Sera-Shriar
 
Decorators in Python
Decorators in PythonDecorators in Python
Decorators in Python
Ben James
 
Wordpress Meetup 2 23 10
Wordpress Meetup 2 23 10Wordpress Meetup 2 23 10
Wordpress Meetup 2 23 10
boonebgorges
 
WordPress and Ajax
WordPress and AjaxWordPress and Ajax
WordPress and Ajax
Ronald Huereca
 
Getting Started With WordPress Development
Getting Started With WordPress DevelopmentGetting Started With WordPress Development
Getting Started With WordPress Development
Andy Brudtkuhl
 
Creatively creating custom post types!
Creatively creating custom post types!Creatively creating custom post types!
Creatively creating custom post types!
techvoltz
 
Creatively creating custom post types!
Creatively creating custom post types!Creatively creating custom post types!
Creatively creating custom post types!
techvoltz
 
Creatively creating custom post types!
Creatively creating custom post types!Creatively creating custom post types!
Creatively creating custom post types!
techvoltz
 

Similar to Custom Post Types and Taxonomies in WordPress (20)

Surviving the Zombie Apocalypse using Custom Post Types and Taxonomies
Surviving the Zombie Apocalypse using Custom Post Types and TaxonomiesSurviving the Zombie Apocalypse using Custom Post Types and Taxonomies
Surviving the Zombie Apocalypse using Custom Post Types and Taxonomies
 
WordCamp Detroit 2010 Wordpress Theme Hacks
WordCamp Detroit 2010 Wordpress Theme HacksWordCamp Detroit 2010 Wordpress Theme Hacks
WordCamp Detroit 2010 Wordpress Theme Hacks
 
WordPress development paradigms, idiosyncrasies and other big words
WordPress development paradigms, idiosyncrasies and other big wordsWordPress development paradigms, idiosyncrasies and other big words
WordPress development paradigms, idiosyncrasies and other big words
 
Sencha Touch Intro
Sencha Touch IntroSencha Touch Intro
Sencha Touch Intro
 
How To Write a WordPress Plugin
How To Write a WordPress PluginHow To Write a WordPress Plugin
How To Write a WordPress Plugin
 
WordPress as a Content Management System
WordPress as a Content Management SystemWordPress as a Content Management System
WordPress as a Content Management System
 
Abstracting functionality with centralised content
Abstracting functionality with centralised contentAbstracting functionality with centralised content
Abstracting functionality with centralised content
 
Moose (Perl 5)
Moose (Perl 5)Moose (Perl 5)
Moose (Perl 5)
 
Moose talk at FOSDEM 2011 (Perl devroom)
Moose talk at FOSDEM 2011 (Perl devroom)Moose talk at FOSDEM 2011 (Perl devroom)
Moose talk at FOSDEM 2011 (Perl devroom)
 
Widgets: Making Your Site Great and Letting Others Help - WordCamp Victoria
Widgets: Making Your Site Great and Letting Others Help - WordCamp VictoriaWidgets: Making Your Site Great and Letting Others Help - WordCamp Victoria
Widgets: Making Your Site Great and Letting Others Help - WordCamp Victoria
 
Creatively creating custom post types! word sesh2
Creatively creating custom post types!  word sesh2Creatively creating custom post types!  word sesh2
Creatively creating custom post types! word sesh2
 
Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010Mongokit presentation mongofr-2010
Mongokit presentation mongofr-2010
 
WordPress Development Confoo 2010
WordPress Development Confoo 2010WordPress Development Confoo 2010
WordPress Development Confoo 2010
 
Decorators in Python
Decorators in PythonDecorators in Python
Decorators in Python
 
Wordpress Meetup 2 23 10
Wordpress Meetup 2 23 10Wordpress Meetup 2 23 10
Wordpress Meetup 2 23 10
 
WordPress and Ajax
WordPress and AjaxWordPress and Ajax
WordPress and Ajax
 
Getting Started With WordPress Development
Getting Started With WordPress DevelopmentGetting Started With WordPress Development
Getting Started With WordPress Development
 
Creatively creating custom post types!
Creatively creating custom post types!Creatively creating custom post types!
Creatively creating custom post types!
 
Creatively creating custom post types!
Creatively creating custom post types!Creatively creating custom post types!
Creatively creating custom post types!
 
Creatively creating custom post types!
Creatively creating custom post types!Creatively creating custom post types!
Creatively creating custom post types!
 

More from Brad Williams

From Freelance to Agency: Hiring Employee Number One - WordCamp London 2015
From Freelance to Agency: Hiring Employee Number One - WordCamp London 2015From Freelance to Agency: Hiring Employee Number One - WordCamp London 2015
From Freelance to Agency: Hiring Employee Number One - WordCamp London 2015
Brad Williams
 
Hiring Employee Number One: From Freelancer to Agency
Hiring Employee Number One: From Freelancer to AgencyHiring Employee Number One: From Freelancer to Agency
Hiring Employee Number One: From Freelancer to Agency
Brad Williams
 
Writing Secure WordPress Code WordCamp NYC 2014
Writing Secure WordPress Code WordCamp NYC 2014Writing Secure WordPress Code WordCamp NYC 2014
Writing Secure WordPress Code WordCamp NYC 2014
Brad Williams
 
How to Make a Native Mobile App with WordPress
How to Make a Native Mobile App with WordPressHow to Make a Native Mobile App with WordPress
How to Make a Native Mobile App with WordPress
Brad Williams
 
Writing Secure WordPress Code
Writing Secure WordPress CodeWriting Secure WordPress Code
Writing Secure WordPress Code
Brad Williams
 
WordPress Security WordCamp OC 2013
WordPress Security WordCamp OC 2013WordPress Security WordCamp OC 2013
WordPress Security WordCamp OC 2013
Brad Williams
 
Using WordPress as an Application Framework
Using WordPress as an Application FrameworkUsing WordPress as an Application Framework
Using WordPress as an Application Framework
Brad Williams
 
Top Ten WordPress Security Tips for 2012
Top Ten WordPress Security Tips for 2012Top Ten WordPress Security Tips for 2012
Top Ten WordPress Security Tips for 2012
Brad Williams
 
WordPress Security from WordCamp NYC 2012
WordPress Security from WordCamp NYC 2012WordPress Security from WordCamp NYC 2012
WordPress Security from WordCamp NYC 2012
Brad Williams
 
WordPress Multisite
WordPress MultisiteWordPress Multisite
WordPress Multisite
Brad Williams
 
WordPress for Beginners
WordPress for BeginnersWordPress for Beginners
WordPress for Beginners
Brad Williams
 
Creating Your First WordPress Plugin
Creating Your First WordPress PluginCreating Your First WordPress Plugin
Creating Your First WordPress Plugin
Brad Williams
 
Intro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentIntro to WordPress Plugin Development
Intro to WordPress Plugin Development
Brad Williams
 
Spooky WordPress: Disturbingly Brilliant Uses of WP
Spooky WordPress: Disturbingly Brilliant Uses of WPSpooky WordPress: Disturbingly Brilliant Uses of WP
Spooky WordPress: Disturbingly Brilliant Uses of WP
Brad Williams
 
WordCamp Mid-Atlantic WordPress Security
WordCamp Mid-Atlantic WordPress SecurityWordCamp Mid-Atlantic WordPress Security
WordCamp Mid-Atlantic WordPress Security
Brad Williams
 
Now That's What I Call WordPress Security 2010
Now That's What I Call WordPress Security 2010Now That's What I Call WordPress Security 2010
Now That's What I Call WordPress Security 2010
Brad Williams
 
Top 20 WordPress Plugins You've Never Heard Of
Top 20 WordPress Plugins You've Never Heard OfTop 20 WordPress Plugins You've Never Heard Of
Top 20 WordPress Plugins You've Never Heard Of
Brad Williams
 
WordPress Security - WordCamp Boston 2010
WordPress Security - WordCamp Boston 2010WordPress Security - WordCamp Boston 2010
WordPress Security - WordCamp Boston 2010
Brad Williams
 
WordPress Security - WordCamp NYC 2009
WordPress Security - WordCamp NYC 2009WordPress Security - WordCamp NYC 2009
WordPress Security - WordCamp NYC 2009
Brad Williams
 
Website Design Dos and Don’ts for a Successful Online Presence
Website Design Dos and Don’ts  for a Successful Online PresenceWebsite Design Dos and Don’ts  for a Successful Online Presence
Website Design Dos and Don’ts for a Successful Online Presence
Brad Williams
 

More from Brad Williams (20)

From Freelance to Agency: Hiring Employee Number One - WordCamp London 2015
From Freelance to Agency: Hiring Employee Number One - WordCamp London 2015From Freelance to Agency: Hiring Employee Number One - WordCamp London 2015
From Freelance to Agency: Hiring Employee Number One - WordCamp London 2015
 
Hiring Employee Number One: From Freelancer to Agency
Hiring Employee Number One: From Freelancer to AgencyHiring Employee Number One: From Freelancer to Agency
Hiring Employee Number One: From Freelancer to Agency
 
Writing Secure WordPress Code WordCamp NYC 2014
Writing Secure WordPress Code WordCamp NYC 2014Writing Secure WordPress Code WordCamp NYC 2014
Writing Secure WordPress Code WordCamp NYC 2014
 
How to Make a Native Mobile App with WordPress
How to Make a Native Mobile App with WordPressHow to Make a Native Mobile App with WordPress
How to Make a Native Mobile App with WordPress
 
Writing Secure WordPress Code
Writing Secure WordPress CodeWriting Secure WordPress Code
Writing Secure WordPress Code
 
WordPress Security WordCamp OC 2013
WordPress Security WordCamp OC 2013WordPress Security WordCamp OC 2013
WordPress Security WordCamp OC 2013
 
Using WordPress as an Application Framework
Using WordPress as an Application FrameworkUsing WordPress as an Application Framework
Using WordPress as an Application Framework
 
Top Ten WordPress Security Tips for 2012
Top Ten WordPress Security Tips for 2012Top Ten WordPress Security Tips for 2012
Top Ten WordPress Security Tips for 2012
 
WordPress Security from WordCamp NYC 2012
WordPress Security from WordCamp NYC 2012WordPress Security from WordCamp NYC 2012
WordPress Security from WordCamp NYC 2012
 
WordPress Multisite
WordPress MultisiteWordPress Multisite
WordPress Multisite
 
WordPress for Beginners
WordPress for BeginnersWordPress for Beginners
WordPress for Beginners
 
Creating Your First WordPress Plugin
Creating Your First WordPress PluginCreating Your First WordPress Plugin
Creating Your First WordPress Plugin
 
Intro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentIntro to WordPress Plugin Development
Intro to WordPress Plugin Development
 
Spooky WordPress: Disturbingly Brilliant Uses of WP
Spooky WordPress: Disturbingly Brilliant Uses of WPSpooky WordPress: Disturbingly Brilliant Uses of WP
Spooky WordPress: Disturbingly Brilliant Uses of WP
 
WordCamp Mid-Atlantic WordPress Security
WordCamp Mid-Atlantic WordPress SecurityWordCamp Mid-Atlantic WordPress Security
WordCamp Mid-Atlantic WordPress Security
 
Now That's What I Call WordPress Security 2010
Now That's What I Call WordPress Security 2010Now That's What I Call WordPress Security 2010
Now That's What I Call WordPress Security 2010
 
Top 20 WordPress Plugins You've Never Heard Of
Top 20 WordPress Plugins You've Never Heard OfTop 20 WordPress Plugins You've Never Heard Of
Top 20 WordPress Plugins You've Never Heard Of
 
WordPress Security - WordCamp Boston 2010
WordPress Security - WordCamp Boston 2010WordPress Security - WordCamp Boston 2010
WordPress Security - WordCamp Boston 2010
 
WordPress Security - WordCamp NYC 2009
WordPress Security - WordCamp NYC 2009WordPress Security - WordCamp NYC 2009
WordPress Security - WordCamp NYC 2009
 
Website Design Dos and Don’ts for a Successful Online Presence
Website Design Dos and Don’ts  for a Successful Online PresenceWebsite Design Dos and Don’ts  for a Successful Online Presence
Website Design Dos and Don’ts for a Successful Online Presence
 

Custom Post Types and Taxonomies in WordPress

  • 1. Custom Post Types and Taxonomies In WordPress Brad Williams WebDevStudios.com
  • 3. Brad Williams Co-Founder of WebDevStudios.com Organizer NJ WordPress Meetup Co-Host SitePoint Podcast Co-Author of Professional WordPress (http://bit.ly/pro-wp) Who Am I?
  • 4. Explain Custom Post Types and Taxonomies Create Custom Post Types Create Custom Taxonomies Hooking into WordPress Topics
  • 5. So what are Custom Post Types?
  • 6. So what are Custom Post Types? CODEX : Post type refers to the various structured data that is maintained in the WordPress posts table. Native (or built-in) post type are  post ,  page ,  attachment ,  revision , and  nav-menu-item . Custom post types are also supported in WordPress and can be defined with  register_post_type() .
  • 8. So what are Custom Post Types Really? ENGLISH : Custom Post Types allow you to create different types of content in WordPress.
  • 9. Default WordPress Post Types: Posts Pages Attachments Revisions Nav Menus (WP 3.0)
  • 10. Custom Post Type Ideas Podcasts Movies Bars Forum Quotes Videos Cars House Listings Events Ticket System etc, etc, etc The possibilities are endless!
  • 11. Example Time! Tweet: @williamsba CAUTION ZOMBIES AHEAD! #wcraleigh Win a copy of Professional WordPress!
  • 13. Example: Zombie Modeling Agency <?php add_action( 'init', 'create_zombie_post_type' ); function create_zombie_post_type() { register_post_type('zombies', array( 'label' => 'Zombies', 'public' => true, ) ); } ?> Drop the below code in your themes functions.php file
  • 14. Example: Zombie Modeling Agency Drop the below code in your themes functions.php file
  • 15. Example: Zombie Modeling Agency <?php add_action( 'init', 'create_zombie_post_type' ); function create_zombie_post_type() { register_post_type('zombies', array( 'label' => 'Zombies', 'public' => true, ) ); } ?> Lets break it down: 1. Action hook to trigger our function 2. Execute the register_post_type function defining zombies as our custom post type 3. Set the label to Zombies 4. Set public to true. By default public is false which will hide your post type
  • 16. Additional Arguments: labels An array of strings that represent your post type in the WP admin name: The plural form of the name of your post type. singular_name: The singular form of the name of your post type. add_new: The menu item for adding a new post. add_new_item: The header shown when creating a new post. edit: The menu item for editing posts. edit_item: The header shown when editing a post. new_item: Shown in the favorites menu in the admin header. view: Used as text in a link to view the post. view_item: Shown alongside the permalink on the edit post screen. search_items: Button text for the search box on the edit posts screen. not_found: Text to display when no posts are found through search in the admin. not_found_in_trash: Text to display when no posts are in the trash. parent: Used as a label for a parent post on the edit posts screen. Only useful for hierarchical post types. Ref: http://justintadlock.com/archives/2010/04/29/custom-post-types-in-wordpress
  • 17. Additional Arguments: labels register_post_type('zombies', array( 'labels' => array( 'name' => 'Zombies', 'singular_name' => 'Zombie', 'add_new' => 'Add New Zombie', 'add_new_item' => 'Add New Zombie', 'edit' => 'Edit Zombies', 'edit_item' => 'Edit Zombie', 'new_item' => 'New Zombie', 'view' => 'View Zombie', 'view_item' => 'View Zombie', 'search_items' => 'Search Zombies', 'not_found' => 'No zombies found', 'not_found_in_trash' => 'No zombies found in Trash', 'parent' => 'Parent Zombie', ), 'public' => true, ) ); An array of strings that represent your post type in the WP admin
  • 18. Additional Arguments: labels The Result
  • 19. Additional Arguments: supports Defines what meta boxes and other fields appear on the edit screen title: Text input field for the post title. editor: Main content meta box comments: Ability to turn comments on/off. trackbacks: Ability to turn trackbacks and pingbacks on/off. revisions: Allows revisions to be made of your post. author: Displays the post author select box. excerpt: A textarea for writing a custom excerpt. thumbnail: The post thumbnail (featured imaged) upload box. custom-fields: Custom fields input area. page-attributes: The attributes box shown for pages. Important for hierarchical post types, so you can select the parent post.
  • 20. Additional Arguments: supports Defines what meta boxes and other fields appear on the edit screen register_post_type('zombies', array( 'labels' => array( 'name' => 'Zombies', 'singular_name' => 'Zombie', 'add_new' => 'Add New Zombie', 'add_new_item' => 'Add New Zombie', 'edit' => 'Edit Zombies', 'edit_item' => 'Edit Zombie', 'new_item' => 'New Zombie', 'view' => 'View Zombie', 'view_item' => 'View Zombie', 'search_items' => 'Search Zombies', 'not_found' => 'No zombies found', 'not_found_in_trash' => 'No zombies found in Trash', 'parent' => 'Parent Zombie', ), 'supports' => array('title'), 'public' => true, ) );
  • 21. Additional Arguments: supports Defines what meta boxes and other fields appear on the edit screen Only the Title and Publish meta boxes are displayed
  • 22. Additional Arguments: supports Now lets activate all meta boxes register_post_type('zombies', array( 'labels' => array( 'name' => 'Zombies', 'singular_name' => 'Zombie', 'add_new' => 'Add New Zombie', 'add_new_item' => 'Add New Zombie', 'edit' => 'Edit Zombies', 'edit_item' => 'Edit Zombie', 'new_item' => 'New Zombie', 'view' => 'View Zombie', 'view_item' => 'View Zombie', 'search_items' => 'Search Zombies', 'not_found' => 'No zombies found', 'not_found_in_trash' => 'No zombies found in Trash', 'parent' => 'Parent Zombie', ), 'supports' => array('title‘,'editor‘,'excerpt‘, 'trackbacks‘,'custom-fields', 'comments‘,'revisions‘,'thumbnail‘,'author‘,'page-attributes'), 'public' => true, ) );
  • 23. Additional Arguments: supports Now all meta boxes are displayed on the Zombie edit screen
  • 24. Additional Arguments: rewrite Defines the permalink structure of your custom post type posts slug: The slug to use in your permalink structure with_front: whether your post type should use the front base from your permalink settings (eg /blog) 'rewrite' => array('slug' => 'zombie') Example: BEFORE AFTER
  • 25. Additional Arguments: taxonomies Add preexisting taxonomies to your custom post type 'taxonomies' => array( 'post_tag', 'category') Example:
  • 26. Additional Arguments: misc Below are additional arguments for creating custom post types hierarchical: whether the post type is hierarchical description: a text description of your custom post type show_ui: whether to show the admin menus/screens menu_position: Set the position of the menu order where the post type should appear menu_icon: URL to the menu icon to be used exclude_from_search: whether post type content should appear in search results
  • 27. Putting it all together register_post_type('zombies', array( 'description' => 'Zombie custom post type', 'show_ui' => true, 'menu_position' => 5, 'menu_icon' => get_stylesheet_directory_uri() . '/images/zombies.png', 'exclude_from_search' => false, 'labels' => array( 'name' => 'Zombies', 'singular_name' => 'Zombie', 'add_new' => 'Add New Zombie', 'add_new_item' => 'Add New Zombie', 'edit' => 'Edit Zombies', 'edit_item' => 'Edit Zombie', 'new_item' => 'New Zombie', 'view' => 'View Zombie', 'view_item' => 'View Zombie', 'search_items' => 'Search Zombies', 'not_found' => 'No zombies found', 'not_found_in_trash' => 'No zombies found in Trash', 'parent' => 'Parent Zombie', ), 'supports' => array('title','editor','excerpt', 'trackbacks','custom-fields', 'comments','revisions','thumbnail','author','page-attributes'), 'public' => true, 'rewrite' => array('slug' => 'zombie', 'with_front' => false), 'taxonomies' => array( 'post_tag', 'category') ) );
  • 28. So what are Taxonomies?
  • 29. So what are Taxonomies? ENGLISH : Taxonomies are a way to group similar items together
  • 30. Default WordPress Taxonomies: Category Tag Link Category
  • 31. Example Time! Tweet: @williamsba ZOMBIES IN AREA! RUN #wcraleigh Win a copy of Professional WordPress!
  • 32. Example: Zombie Modeling Agency <?php add_action( 'init', 'create_zombie_taxonomies' ); function create_zombie_taxonomies() { register_taxonomy( 'freshness', 'zombies', array( 'hierarchical' => false, 'label' => 'Freshness' ) ); } ?> Drop the below code in your themes functions.php file Non-hierarchical Taxonomy
  • 33. Example: Zombie Modeling Agency New custom taxonomy is automatically added to the Zombies post type menu The Freshness meta box is also automatically added to the Zombie edit screen automatically!
  • 34. Example: Zombie Modeling Agency <?php add_action( 'init', 'create_zombie_taxonomies' ); function create_zombie_taxonomies() { register_taxonomy( 'freshness', 'zombies', array( 'hierarchical' => true, 'label' => 'Freshness' ) ); } ?> Drop the below code in your themes functions.php file Hierarchical Taxonomy
  • 35. Example: Zombie Modeling Agency New custom taxonomy is automatically added to the Zombies post type menu The Freshness meta box is also automatically added to the Zombie edit screen automatically!
  • 36. Example: Zombie Modeling Agency Lets break it down: Action hook to trigger our function Execute the register_taxonomy function defining freshness as our custom taxonomy Set the name to freshness Set the object type to ‘zombies’. Must be an existing post type Set hierarchical to false Set our taxonomy label to Freshness <?php add_action( 'init', 'create_zombie_taxonomies' ); function create_zombie_taxonomies() { register_taxonomy( 'freshness', 'zombies', array( 'hierarchical' => false, 'label' => 'Freshness' ) ); } ?>
  • 37. Additional Arguments: labels An array of strings that represent your taxonomy in the WP admin name: The general name of your taxonomy singular_name: The singular form of the name of your taxonomy. search_items: The search items text popular_items: The popular items text all_items: The all items text parent_item: The parent item text. Only used on hierarchical taxonomies parent_item_colon: Same as parent_item, but with a colon edit_item: The edit item text update_item: The update item text add_new_item: The add new item text new_item_name: The new item name text
  • 38. Additional Arguments: labels register_taxonomy( 'freshness', 'zombies', array( 'labels' => array( 'name' => 'Freshness', 'singular_name' => 'Freshness', 'search_items' => 'Search Freshness', 'popular_items' => 'Popular Freshness', 'all_items' => 'All Freshness', 'parent_item' => 'Parent Freshness', 'parent_item_colon' => 'Parent Freshness:', 'edit_item' => 'Edit Freshness', 'update_item' => 'Update Freshness', 'add_new_item' => 'Add New Freshness', 'new_item_name' => 'New Freshness Name' ), 'hierarchical' => false, 'label' => 'Freshness' ) ); An array of strings that represent your taxonomy in the WP admin
  • 40. Additional Arguments: rewrite Defines the permalink structure for your custom taxonomy slug: The slug to use in your permalink structure with_front: whether your taxonomy should use the front base from your permalink settings (eg /blog) 'rewrite' => array('slug' => fresh') Example: BEFORE AFTER http://x.webdevstudios.com/blog/freshness/ripe/ http://x.webdevstudios.com/blog/fresh/ripe/
  • 41. Additional Arguments: misc Below are additional arguments for creating custom taxonomies public: whether the taxonomy is publicly queryable show_ui: whether to display the admin UI for the taxonomy hierarchical: whether the taxonomy is hierarchical. Categories are hierarchical, tags are not. label: the name of your taxonomy in the admin dashboard query_var: whether to be able to query posts using the taxonomy. rewrite: whether to use a pretty permalink when viewing the taxonomy page. show_tagcloud: whether to show a tag cloud in the admin UI
  • 42. Putting it all together register_taxonomy( 'freshness', 'zombies', array( 'labels' => array( 'name' => 'Freshness', 'singular_name' => 'Freshness', 'search_items' => 'Search Freshness', 'popular_items' => 'Popular Freshness', 'all_items' => 'All Freshness', 'parent_item' => 'Parent Freshness', 'parent_item_colon' => 'Parent Freshness:', 'edit_item' => 'Edit Freshness', 'update_item' => 'Update Freshness', 'add_new_item' => 'Add New Freshness', 'new_item_name' => 'New Freshness Name' ), 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'query_var' => 'freshness', 'show_tagcloud' => true, 'rewrite' => array( 'slug' => 'fresh', 'with_front' => false ) ) );
  • 43.  
  • 45. Displaying Custom Post Type Content <?php query_posts( array( 'post_type' => 'zombies' ) ); ?> By default custom post type content will NOT display in the Loop Placing the above code directly before the Loop will only display our zombies
  • 46. Displaying Custom Post Type Content <?php query_posts( array( 'post_type' => 'zombies' ) ); ?> BEFORE ZOMBIED (After)
  • 47. Custom Loop <?php $zombies = new WP_Query( array( 'post_type' => 'zombies', 'posts_per_page' => 1, 'orderby' => 'rand' ) ); while ( $zombies->have_posts() ) : $zombies->the_post(); the_title( '<h2><a href=&quot;' . get_permalink() . '&quot; >', '</a></h2>' ); ?> <div class=&quot;entry-content&quot;> <?php the_content(); ?> </div> <?php endwhile; ?> Creating a custom Loop for your post type
  • 48. <?php if (have_posts()) : while (have_posts()) : the_post(); $post_type = get_post_type( get_the_ID() ); if ($post_type == 'zombies') { echo 'This is a Zombie!'; } ?> <?php endwhile; ?> <?php endif; ?> Function: get_post_type() Returns the post type of the content you are viewing Custom Post Type Functions http://codex.wordpress.org/Function_Reference/get_post_type
  • 49. if ( is_post_type( 'zombies' ) ) { echo 'Zombies Exist!'; } Function: is_post_type() Check if a post type exists Custom Post Type Functions if ( is_post_type( 'zombies' $post_id) ) { echo ‘Post ID: ‘ .$post_id .‘is a Zombie!'; } Can also check a specific post against a post type
  • 50. <?php echo get_the_term_list( $post->ID, 'freshness', 'Freshness: ', ', ', '' ); ?> Function: get_the_term_list() Display freshness taxonomy for our zombies Custom Taxonomy Functions http://codex.wordpress.org/Function_Reference/get_the_term_list
  • 52. Custom Post Type UI http://wordpress.org/extend/plugins/custom-post-type-ui/ Easily create custom post types without writing code!
  • 53. Custom Post Type UI http://wordpress.org/extend/plugins/custom-post-type-ui/ Also easily create custom taxonomies without writing code!
  • 54. Custom Post Type UI http://wordpress.org/extend/plugins/custom-post-type-ui/ Plugin also gives you the PHP code for custom post types and taxonomies!
  • 55. Related Codex Articles http://codex.wordpress.org/Hardening_WordPress Custom Post Type Articles http://justintadlock.com/archives/2010/04/29/custom-post-types-in-wordpress http://justintadlock.com/archives/2010/02/02/showing-custom-post-types-on-your-home-blog-page http://kovshenin.com/archives/custom-post-types-in-wordpress-3-0/ http://wpengineer.com/impressions-of-custom-post-type/ Custom Taxonomies http://justintadlock.com/archives/2009/05/06/custom-taxonomies-in-wordpress-28 http://justintadlock.com/archives/2009/06/04/using-custom-taxonomies-to-create-a-movie-database http://www.shibashake.com/wordpress-theme/wordpress-custom-taxonomy-input-panels Custom Post Type and Taxonomy Resources
  • 56. Brad Williams [email_address] Blog: strangework.com Twitter: @williamsba IRC: WDS-Brad Contact Professional WordPress: http://bit.ly/pro-wp