SlideShare a Scribd company logo
@mlteal | #WPAZ | July 2015
Custom Post Types
If it’s not a post, and it’s not a page…
@mlteal | #WPAZ | July 2015
Post v Post Type
A page, a blog post, and a navigation menu…

they’re all a type of “post”.
https://codex.wordpress.org/Post_Types
WordPress also considers revisions and attachments as
types of “posts”.
@mlteal | #WPAZ | July 2015
Post = Blob
No, really. A “post” in this case is just a
chunk of content that stores info in the
wp_posts and wp_postmeta tables.
@mlteal | #WPAZ | July 2015
Who Cares?
I do, because I like organization.
@mlteal | #WPAZ | July 2015
Who Cares?
Anyone who wants to organize unique 

types of content.
- Portfolio items

- Products

- Testimonials
@mlteal | #WPAZ | July 2015
@mlteal | #WPAZ | July 2015
How to add a CPT
• Add via plugin
• Build the plugin (need to
know how to upload/edit
files on server)
• Find one that suits your
needs
• Build with something like
Types and Views
@mlteal | #WPAZ | July 2015
Building the Plugin
1. Create folder in plugins directory
(ex: my-plugin)
2. Create plugin file inside that folder
(ex: my-plugin.php)
@mlteal | #WPAZ | July 2015
Building the Plugin
Add plugin header information:
/**

* Plugin Name: MLT Portfolio

* Plugin URI: http://mlteal.com

* Author: Maura Teal

* Description: A plugin that adds a Portfolio cpt

* Version: 0.1

*/
@mlteal | #WPAZ | July 2015
Building the Plugin
Add a function that registers the CPT, and
an action that tells WordPress to run it.
function mlt_custom_post_type() {

$labels = array(

'name' => 'Portfolio',

);

$args = array(

'labels' => $labels,

'public' => true,

);

register_post_type( 'mlt-portfolio', $args );

}



add_action( 'init', 'mlt_custom_post_type' );
@mlteal | #WPAZ | July 2015
Live Demo
@mlteal | #WPAZ | July 2015
CPT’s in Themes or Plugins?
• Plugins. CPT’s packaged
with themes are for
convenience of selling.
• What happens when you
change out the theme?
@mlteal | #WPAZ | July 2015
Resources
Can’t see your CPT when you try to view post? 

Visit Settings -> Permalinks from the dashboard
Generate CPT code: 

http://generatewp.com/post-type/
CPT Tutorial: 

https://www.elegantthemes.com/blog/tips-tricks/
creating-custom-post-types-in-wordpress

More Related Content

PPTX
Power of mu plugins
PDF
The Ultimate Getting Started with Angular Workshop - Devoxx France 2017
PDF
Building Cloud Native Progressive Web Apps with Angular and Spring Boot - Dev...
PDF
What's New in JHipsterLand - Devoxx US 2017
PDF
Building an app across 11 arabic countries
PDF
Getting Started With Sass | WC Philly 2015
PDF
wp cli- don’t fear the command line
PDF
Custom post types- Choose Your Own Adventure - WordCamp Atlanta 2014 - Evan M...
Power of mu plugins
The Ultimate Getting Started with Angular Workshop - Devoxx France 2017
Building Cloud Native Progressive Web Apps with Angular and Spring Boot - Dev...
What's New in JHipsterLand - Devoxx US 2017
Building an app across 11 arabic countries
Getting Started With Sass | WC Philly 2015
wp cli- don’t fear the command line
Custom post types- Choose Your Own Adventure - WordCamp Atlanta 2014 - Evan M...

Similar to Intro to Custom Post Types WPAZ July 2015 (20)

PDF
Add Custom Post Types to Your WordPress Website
PPTX
WordPress - Create Custom Post Types
PDF
WordPress custom posts types for structured content
KEY
Custom post types - WordPress
PPTX
Wordpress custom-posttype
PDF
Custom Post Type - Create and Display
KEY
Custom Post Types - What, Why, and How
PDF
WordPress Custom Post Type
PDF
WordPress Custom Post Types
PDF
Stepping Into Custom Post Types
KEY
WordPress 3 Custom Post Types
PDF
WordPress Custom Post Types
KEY
Custom Post Types in Depth at WordCamp Montreal
PDF
Workshop: Creating your first WordPress plugin
PPTX
The Flexibility of WordPress
PPTX
Custom Post Types - WordPress
PPT
An Introduction to Custom Post Types
PDF
Custom content types & custom taxonomies in wordpress
PDF
Custom Post Types--Front End
PDF
A Beginner's Guide to Popping the Bonnet and Getting Your Hands Dirty
Add Custom Post Types to Your WordPress Website
WordPress - Create Custom Post Types
WordPress custom posts types for structured content
Custom post types - WordPress
Wordpress custom-posttype
Custom Post Type - Create and Display
Custom Post Types - What, Why, and How
WordPress Custom Post Type
WordPress Custom Post Types
Stepping Into Custom Post Types
WordPress 3 Custom Post Types
WordPress Custom Post Types
Custom Post Types in Depth at WordCamp Montreal
Workshop: Creating your first WordPress plugin
The Flexibility of WordPress
Custom Post Types - WordPress
An Introduction to Custom Post Types
Custom content types & custom taxonomies in wordpress
Custom Post Types--Front End
A Beginner's Guide to Popping the Bonnet and Getting Your Hands Dirty
Ad

Recently uploaded (20)

PPTX
MYSQL Presentation for SQL database connectivity
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Cloud computing and distributed systems.
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
cuic standard and advanced reporting.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Electronic commerce courselecture one. Pdf
PPTX
Spectroscopy.pptx food analysis technology
PDF
Empathic Computing: Creating Shared Understanding
PPTX
A Presentation on Artificial Intelligence
MYSQL Presentation for SQL database connectivity
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Cloud computing and distributed systems.
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
A comparative analysis of optical character recognition models for extracting...
Assigned Numbers - 2025 - Bluetooth® Document
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Machine learning based COVID-19 study performance prediction
Building Integrated photovoltaic BIPV_UPV.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
“AI and Expert System Decision Support & Business Intelligence Systems”
gpt5_lecture_notes_comprehensive_20250812015547.pdf
cuic standard and advanced reporting.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Network Security Unit 5.pdf for BCA BBA.
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Electronic commerce courselecture one. Pdf
Spectroscopy.pptx food analysis technology
Empathic Computing: Creating Shared Understanding
A Presentation on Artificial Intelligence
Ad

Intro to Custom Post Types WPAZ July 2015

  • 1. @mlteal | #WPAZ | July 2015 Custom Post Types If it’s not a post, and it’s not a page…
  • 2. @mlteal | #WPAZ | July 2015 Post v Post Type A page, a blog post, and a navigation menu…
 they’re all a type of “post”. https://codex.wordpress.org/Post_Types WordPress also considers revisions and attachments as types of “posts”.
  • 3. @mlteal | #WPAZ | July 2015 Post = Blob No, really. A “post” in this case is just a chunk of content that stores info in the wp_posts and wp_postmeta tables.
  • 4. @mlteal | #WPAZ | July 2015 Who Cares? I do, because I like organization.
  • 5. @mlteal | #WPAZ | July 2015 Who Cares? Anyone who wants to organize unique 
 types of content. - Portfolio items
 - Products
 - Testimonials
  • 6. @mlteal | #WPAZ | July 2015
  • 7. @mlteal | #WPAZ | July 2015 How to add a CPT • Add via plugin • Build the plugin (need to know how to upload/edit files on server) • Find one that suits your needs • Build with something like Types and Views
  • 8. @mlteal | #WPAZ | July 2015 Building the Plugin 1. Create folder in plugins directory (ex: my-plugin) 2. Create plugin file inside that folder (ex: my-plugin.php)
  • 9. @mlteal | #WPAZ | July 2015 Building the Plugin Add plugin header information: /**
 * Plugin Name: MLT Portfolio
 * Plugin URI: http://mlteal.com
 * Author: Maura Teal
 * Description: A plugin that adds a Portfolio cpt
 * Version: 0.1
 */
  • 10. @mlteal | #WPAZ | July 2015 Building the Plugin Add a function that registers the CPT, and an action that tells WordPress to run it. function mlt_custom_post_type() {
 $labels = array(
 'name' => 'Portfolio',
 );
 $args = array(
 'labels' => $labels,
 'public' => true,
 );
 register_post_type( 'mlt-portfolio', $args );
 }
 
 add_action( 'init', 'mlt_custom_post_type' );
  • 11. @mlteal | #WPAZ | July 2015 Live Demo
  • 12. @mlteal | #WPAZ | July 2015 CPT’s in Themes or Plugins? • Plugins. CPT’s packaged with themes are for convenience of selling. • What happens when you change out the theme?
  • 13. @mlteal | #WPAZ | July 2015 Resources Can’t see your CPT when you try to view post? 
 Visit Settings -> Permalinks from the dashboard Generate CPT code: 
 http://generatewp.com/post-type/ CPT Tutorial: 
 https://www.elegantthemes.com/blog/tips-tricks/ creating-custom-post-types-in-wordpress