SlideShare una empresa de Scribd logo
1 de 36
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

Más contenido relacionado

La actualidad más candente

La actualidad más candente (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
 

Destacado (6)

Présentation PARIS en Australie
Présentation PARIS en AustraliePrésentation PARIS en Australie
Présentation PARIS en Australie
 
Création de site avec ou sans agence, Présentation Emilie ROY
Création de site avec ou sans agence, Présentation Emilie ROY  Création de site avec ou sans agence, Présentation Emilie ROY
Création de site avec ou sans agence, Présentation Emilie ROY
 
Agence HEREZIE - L'agence
Agence HEREZIE - L'agenceAgence HEREZIE - L'agence
Agence HEREZIE - L'agence
 
The mooc agency - Web-conférence du FFFOD du 10/12/13
The mooc agency - Web-conférence du FFFOD du 10/12/13The mooc agency - Web-conférence du FFFOD du 10/12/13
The mooc agency - Web-conférence du FFFOD du 10/12/13
 
Sqli Agency Suisse - Talk x Design x Share - Episode 1 - HTML5 and Mobile Fir...
Sqli Agency Suisse - Talk x Design x Share - Episode 1 - HTML5 and Mobile Fir...Sqli Agency Suisse - Talk x Design x Share - Episode 1 - HTML5 and Mobile Fir...
Sqli Agency Suisse - Talk x Design x Share - Episode 1 - HTML5 and Mobile Fir...
 
Sqli Agency Suisse - Talk x Design x Share - Episode 2 - From Pens to Pixels
Sqli Agency Suisse - Talk x Design x Share - Episode 2 - From Pens to PixelsSqli Agency Suisse - Talk x Design x Share - Episode 2 - From Pens to Pixels
Sqli Agency Suisse - Talk x Design x Share - Episode 2 - From Pens to Pixels
 

Similar a 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 a 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
 

Último

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Último (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
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...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 

Creatively creating custom post types!

Notas del editor

  1. (If you’re curious, I am 5,230 days old)
  2. Many different types of combos
  3. This adds an action for your custom post type in the Dashboard, but it will not be there just yet…
  4. ‘Query_var’ Querying posts of this type from the database
  5. ‘query_var’ Is the $posttype
  6. ‘query_var’ is the name of the $posttype
  7. Like a Dewey Decimal system at a public library
  8. Examine all the code!!
  9. This adds an action for your taxonomy in the Dashboard, but it will not be there just yet…
  10. A list of tags
  11. Now we register the taxonomy to our custom post type.
  12. And different kinds of meta data