SlideShare a Scribd company logo
1 of 36
Download to read offline
Creatively Creating Custom
Post Types
NikhilVimal
#WordUpMPLS
Hi, I’m Nikhil
• I develop with WordPress
• I can be found on Twitter @TechVoltz
• This my first talk ever
Custom Post Types?
They Rock (Seriously)
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
Why Do You need them?
Organization
Portfolio
Post Type could be paintings
Online Store
Post Type could be Products
Your only limitation is
Your imagination
“WordPress can hold and display many different
types of content.”
-WordPress Codex
But how do we add
Custom Post Types?
With a plugin of course
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
*/
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 );
}
Lets examine all the
code!!
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 Sessions',
'not_found' => 'No sessions found',
'not_found_in_trash' => 'No Sessions found in the Trash',
),
);
register_post_type('WordUp', $wordup_args );
}
Styling your CPT Page
With single-$posttype.php
Having an Archive Page for
your CPT
With archive-$posttype.php
Taxonomies
More Organization
“Basically, a taxonomy is a way to group things
together”
-WordPress Codex
Taxonomies
Categories and Tags
Portfolio
Taxonomy is oil painting
After our Custom Post
type function….
add_action('init', 'wordup_tracks');
function wordup_tracks(){
$track_args = array(
'hierarchical' => true,
'query_var' => ‘wordup_tracks',
'show_tagcloud' => true,
'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',
),
);
register_taxonomy(‘wordup_tracks',
array('wordup'), $dev_args);
}
The array(‘wordup’) is our custom post type
You can add more
Like Custom Fields
Questions?
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/
Thank You!
Nikhil Vimal
@TechVoltz

More Related Content

What's hot (12)

php (Hypertext Preprocessor)
php (Hypertext Preprocessor)php (Hypertext Preprocessor)
php (Hypertext Preprocessor)
 
Pemrograman Web 9 - Input Form DB dan Session
Pemrograman Web 9 - Input Form DB dan SessionPemrograman Web 9 - Input Form DB dan Session
Pemrograman Web 9 - Input Form DB dan Session
 
Add edit delete in Codeigniter in PHP
Add edit delete in Codeigniter in PHPAdd edit delete in Codeigniter in PHP
Add edit delete in Codeigniter in PHP
 
12. CodeIgniter vederea inregistrarilor2
12. CodeIgniter vederea inregistrarilor212. CodeIgniter vederea inregistrarilor2
12. CodeIgniter vederea inregistrarilor2
 
Country State City Dropdown in PHP
Country State City Dropdown in PHPCountry State City Dropdown in PHP
Country State City Dropdown in PHP
 
Pagination in PHP
Pagination in PHPPagination in PHP
Pagination in PHP
 
php $_GET / $_POST / $_SESSION
php  $_GET / $_POST / $_SESSIONphp  $_GET / $_POST / $_SESSION
php $_GET / $_POST / $_SESSION
 
Add loop shortcode
Add loop shortcodeAdd loop shortcode
Add loop shortcode
 
WordPress for developers - phpday 2011
WordPress for developers -  phpday 2011WordPress for developers -  phpday 2011
WordPress for developers - phpday 2011
 
jQuery Awesomesauce
jQuery AwesomesaucejQuery Awesomesauce
jQuery Awesomesauce
 
Pemrograman Web 8 - MySQL
Pemrograman Web 8 - MySQLPemrograman Web 8 - MySQL
Pemrograman Web 8 - MySQL
 
bcgr3-jquery
bcgr3-jquerybcgr3-jquery
bcgr3-jquery
 

Viewers also liked

Adobe phonegap-workshop-2013
Adobe phonegap-workshop-2013Adobe phonegap-workshop-2013
Adobe phonegap-workshop-2013
Haig Armen
 
Introduction to wireframing ux and design
Introduction to wireframing ux and designIntroduction to wireframing ux and design
Introduction to wireframing ux and design
Kevin Picalausa
 

Viewers also liked (7)

TOC Workshop 2013
TOC Workshop 2013TOC Workshop 2013
TOC Workshop 2013
 
Adobe phonegap-workshop-2013
Adobe phonegap-workshop-2013Adobe phonegap-workshop-2013
Adobe phonegap-workshop-2013
 
Client is a human too
Client is a human tooClient is a human too
Client is a human too
 
Designing Mineblock: Merging Physical & Digital to create Meta Products
Designing Mineblock: Merging Physical & Digital to create Meta ProductsDesigning Mineblock: Merging Physical & Digital to create Meta Products
Designing Mineblock: Merging Physical & Digital to create Meta Products
 
Introduction to wireframing ux and design
Introduction to wireframing ux and designIntroduction to wireframing ux and design
Introduction to wireframing ux and design
 
Midwest UX Mobile Workshop 2012
Midwest UX Mobile Workshop 2012Midwest UX Mobile Workshop 2012
Midwest UX Mobile Workshop 2012
 
Design Driven & Agile
Design Driven & AgileDesign Driven & Agile
Design Driven & Agile
 

Similar to Creatively creating custom post types!

Extending WordPress. Making use of Custom Post Types
Extending WordPress. Making use of Custom Post TypesExtending WordPress. Making use of Custom Post Types
Extending WordPress. Making use of Custom Post Types
Utsav Singh Rathour
 
WordPress Developers Israel Meetup #1
WordPress Developers Israel Meetup #1WordPress Developers Israel Meetup #1
WordPress Developers Israel Meetup #1
Yoav Farhi
 
Building a Portfolio With Custom Post Types
Building a Portfolio With Custom Post TypesBuilding a Portfolio With Custom Post Types
Building a Portfolio With Custom Post Types
Alex Blackie
 
Stepping Into Custom Post Types
Stepping Into Custom Post TypesStepping Into Custom Post Types
Stepping Into Custom Post Types
K.Adam White
 
Gail villanueva add muscle to your wordpress site
Gail villanueva   add muscle to your wordpress siteGail villanueva   add muscle to your wordpress site
Gail villanueva add muscle to your wordpress site
references
 
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
 
Mongo and Harmony
Mongo and HarmonyMongo and Harmony
Mongo and Harmony
Steve Smith
 

Similar to Creatively creating custom post types! (20)

Extending WordPress. Making use of Custom Post Types
Extending WordPress. Making use of Custom Post TypesExtending WordPress. Making use of Custom Post Types
Extending WordPress. Making use of Custom Post Types
 
Custom Post Types and Meta Fields
Custom Post Types and Meta FieldsCustom Post Types and Meta Fields
Custom Post Types and Meta Fields
 
WordPress Developers Israel Meetup #1
WordPress Developers Israel Meetup #1WordPress Developers Israel Meetup #1
WordPress Developers Israel Meetup #1
 
Building a Portfolio With Custom Post Types
Building a Portfolio With Custom Post TypesBuilding a Portfolio With Custom Post Types
Building a Portfolio With Custom Post Types
 
Intro to WordPress theme development
Intro to WordPress theme developmentIntro to WordPress theme development
Intro to WordPress theme development
 
Custom post types- Choose Your Own Adventure - WordCamp Atlanta 2014 - Evan M...
Custom post types- Choose Your Own Adventure - WordCamp Atlanta 2014 - Evan M...Custom post types- Choose Your Own Adventure - WordCamp Atlanta 2014 - Evan M...
Custom post types- Choose Your Own Adventure - WordCamp Atlanta 2014 - Evan M...
 
How To Write a WordPress Plugin
How To Write a WordPress PluginHow To Write a WordPress Plugin
How To Write a WordPress Plugin
 
The Way to Theme Enlightenment
The Way to Theme EnlightenmentThe Way to Theme Enlightenment
The Way to Theme Enlightenment
 
The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017
 
Custom Post Types in WP3
Custom Post Types in WP3Custom Post Types in WP3
Custom Post Types in WP3
 
Stepping Into Custom Post Types
Stepping Into Custom Post TypesStepping Into Custom Post Types
Stepping Into Custom Post Types
 
Gail villanueva add muscle to your wordpress site
Gail villanueva   add muscle to your wordpress siteGail villanueva   add muscle to your wordpress site
Gail villanueva add muscle to your wordpress site
 
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
 
Bending word press to your will
Bending word press to your willBending word press to your will
Bending word press to your will
 
Custom Post Type - Create and Display
Custom Post Type - Create and DisplayCustom Post Type - Create and Display
Custom Post Type - Create and Display
 
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
 
[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018
 
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
 
Mongo and Harmony
Mongo and HarmonyMongo and Harmony
Mongo and Harmony
 
Custom Fields & Custom Metaboxes Overview
Custom Fields & Custom Metaboxes OverviewCustom Fields & Custom Metaboxes Overview
Custom Fields & Custom Metaboxes Overview
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Recently uploaded (20)

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 

Creatively creating custom post types!