SlideShare a Scribd company logo
1 of 16
WP 201: Custom Post Types,
Custom Fields
WordCamp Columbus 2015 #wccbus | #wp201cp
 Before we describe what a custom post type is, let’s review what is
a post type?
 In WordPress there are 5 post types.
 Post – Blog Entry
 Page – Static Content that doesn’t expire or change.
 Attachment – Document, Image, Video, etc.
 Revision – Version of a Post or Page
 Navigation Menu Item
 A Custom Post Type, is one that you create!
What are Custom Post Types?
 Content that needs to be structured in a certain way, and you wish
to provide a template to ensure the content is always represented
the same.
 Examples:
 Recipes
 Products (non-ecommerce)
 Frequently Asked Questions
 etc.
Why create a Custom Post Type?
How Do I Create a Custom Post
Type?
add_action( 'init', 'create_post_type' );
function create_post_type() {
register_post_type( 'acme_product',
array(
'labels' => array(
'name' => __( 'Products' ),
'singular_name' => __( 'Product' )
),
'public' => true,
'has_archive' => true,
)
);
}
Sample: https://codex.wordpress.org/Post_Types
 Where do I put the code?
 You could put the code in your themesfunctions.php file.
How Do I Create a Custom Post
Type?
Example Scenario
 Let’s say you have a food blog and you want to use a custom
post type to display your recipes.
 So you use the awesome code we just looked at, customized
it to represent your menu offerings. Created categories for
breakfast, lunch, dinner, appetizers, desserts.
 You have populated your menu with all of your fantastic
recipes.
 Life is good!
Example Scenario
 Now let’s say 3 months or 6 months, or maybe even a whole
year goes by, and everything is still good.
 Then you find the ultimate theme, it’s great, it looks just like
you want your website to look.
 So you install it, then you activate it.
 Then later that day or the next someone emails and asks
where are your recipes, so you tell them to click on recipes,
and they ask WHERE? I’m on your site and there are no
recipes.
Example Scenario
 So you go to your site and check. Hmmm no menu….
 Then in 3…2…1.. You panic!
 Where do I put the code?
 You could put the code in your themesfunctions.php file.
 A better place would be in a plugin!
 A plugin won’t cause your content to disappear.
 How do I create a plugin?
How Do I Create a Custom Post
Type?
Code Demo
What is a Custom Field?
 The Codex defines a custom field as meta-data, that contains
a key/value pair.
 ??????
What is a Custom Field?
 Even I admit it’s pretty technical and confusing.
 If you keep reading the codex page though you’ll see what a
key/value pair is.
 Key – the name of the meta-data
 Value – the meta-data
 Example:
 Key: Currently Reading
 Value: Calvin and Hobbes
What can I do with a Custom
Field?
 You need a feature for your website, such as
announcements.
 First you create a custom post type to handle the
announcement content.
 Title
 Description
 Photo
 It would be cool if I could make announcements appear
automatically on a certain date and disappear automatically
on a certain date.
What can I do with a Custom
Field?
 Create a custom field
 Start Date – built in scheduling of post
 Display End Date
 Importance
 Using some PHP logic when displaying the content we can
automatically display based upon the server’s date the
content, as well as stop displaying it.
 Using similar PHP logic, we can change the CSS class or ID
of the containing element to make the announcement stand
out.
Code Demo
Links Mentioned
 www.generatewp.com – various form based generators for
code snippets in WordPress
 WP Beginner – Site Specific plugin –
http://www.wpbeginner.com/beginners-guide/what-why-and-
how-tos-of-creating-a-site-specific-wordpress-plugin/
 Recipe Custom Post Type Example –
https://gist.github.com/joecue/d0a5e37f3d1bbe17ae1f
 Announcement Custom Field (Meta Box) and Custom Post
Type Example –
https://gist.github.com/joecue/7d2339e4e9a8b16ab0a4

More Related Content

What's hot

WordPress SEO & Optimisation
WordPress SEO & OptimisationWordPress SEO & Optimisation
WordPress SEO & OptimisationJoost de Valk
 
Wp snapper review
Wp snapper reviewWp snapper review
Wp snapper reviewDilip Kumar
 
Instagram filters
Instagram filters Instagram filters
Instagram filters Thinkful
 
Alicia Lyttle & Lorette Lyttle of Monetized Marketing - WordPress Wednesday –...
Alicia Lyttle & Lorette Lyttle of Monetized Marketing - WordPress Wednesday –...Alicia Lyttle & Lorette Lyttle of Monetized Marketing - WordPress Wednesday –...
Alicia Lyttle & Lorette Lyttle of Monetized Marketing - WordPress Wednesday –...justcess
 
Blogging for business
Blogging for businessBlogging for business
Blogging for businessSpiderworking
 
WordPress plugin development
WordPress plugin developmentWordPress plugin development
WordPress plugin developmentarryaas
 
WP Style Guide Sep 23 2009.pptx
WP Style Guide Sep 23 2009.pptxWP Style Guide Sep 23 2009.pptx
WP Style Guide Sep 23 2009.pptxnickohrn
 
WordCamp Ireland - 40 tips for WordPress Optimization
WordCamp Ireland - 40 tips for WordPress OptimizationWordCamp Ireland - 40 tips for WordPress Optimization
WordCamp Ireland - 40 tips for WordPress OptimizationJoost de Valk
 
Rock Your Blocks! Web Design Acceleration with Genesis Pro
Rock Your Blocks! Web Design Acceleration with Genesis ProRock Your Blocks! Web Design Acceleration with Genesis Pro
Rock Your Blocks! Web Design Acceleration with Genesis ProWP Engine
 
Advanced custom fields in Wordpress
Advanced custom fields in WordpressAdvanced custom fields in Wordpress
Advanced custom fields in WordpressExove
 
10 Steps to Becoming a WordPress Theme Ninja
10 Steps to Becoming a WordPress Theme Ninja10 Steps to Becoming a WordPress Theme Ninja
10 Steps to Becoming a WordPress Theme NinjaTony Cecala, Ph.D.
 
What to include in a boilerplate theme
What to include in a boilerplate themeWhat to include in a boilerplate theme
What to include in a boilerplate themeTim Brown
 
Between a Block & a Hard Place
Between a Block & a Hard PlaceBetween a Block & a Hard Place
Between a Block & a Hard PlaceWP Engine
 

What's hot (19)

WordPress SEO & Optimisation
WordPress SEO & OptimisationWordPress SEO & Optimisation
WordPress SEO & Optimisation
 
Wp snapper review
Wp snapper reviewWp snapper review
Wp snapper review
 
Instagram filters
Instagram filters Instagram filters
Instagram filters
 
Blogging for champions
Blogging for championsBlogging for champions
Blogging for champions
 
Alicia Lyttle & Lorette Lyttle of Monetized Marketing - WordPress Wednesday –...
Alicia Lyttle & Lorette Lyttle of Monetized Marketing - WordPress Wednesday –...Alicia Lyttle & Lorette Lyttle of Monetized Marketing - WordPress Wednesday –...
Alicia Lyttle & Lorette Lyttle of Monetized Marketing - WordPress Wednesday –...
 
Blogging for business
Blogging for businessBlogging for business
Blogging for business
 
WordPress plugin development
WordPress plugin developmentWordPress plugin development
WordPress plugin development
 
WP Style Guide Sep 23 2009.pptx
WP Style Guide Sep 23 2009.pptxWP Style Guide Sep 23 2009.pptx
WP Style Guide Sep 23 2009.pptx
 
WordCamp Ireland - 40 tips for WordPress Optimization
WordCamp Ireland - 40 tips for WordPress OptimizationWordCamp Ireland - 40 tips for WordPress Optimization
WordCamp Ireland - 40 tips for WordPress Optimization
 
Blogging 101, VT HRC
Blogging 101, VT HRCBlogging 101, VT HRC
Blogging 101, VT HRC
 
Rock Your Blocks! Web Design Acceleration with Genesis Pro
Rock Your Blocks! Web Design Acceleration with Genesis ProRock Your Blocks! Web Design Acceleration with Genesis Pro
Rock Your Blocks! Web Design Acceleration with Genesis Pro
 
Advanced custom fields in Wordpress
Advanced custom fields in WordpressAdvanced custom fields in Wordpress
Advanced custom fields in Wordpress
 
Child Theme
Child ThemeChild Theme
Child Theme
 
10 Steps to Becoming a WordPress Theme Ninja
10 Steps to Becoming a WordPress Theme Ninja10 Steps to Becoming a WordPress Theme Ninja
10 Steps to Becoming a WordPress Theme Ninja
 
What to include in a boilerplate theme
What to include in a boilerplate themeWhat to include in a boilerplate theme
What to include in a boilerplate theme
 
Between a Block & a Hard Place
Between a Block & a Hard PlaceBetween a Block & a Hard Place
Between a Block & a Hard Place
 
Web development basics2
Web development basics2Web development basics2
Web development basics2
 
SEO Mistakes
SEO MistakesSEO Mistakes
SEO Mistakes
 
Permalink
PermalinkPermalink
Permalink
 

Viewers also liked

Responsive Theme Workshop - WordCamp Columbus 2015
Responsive Theme Workshop - WordCamp Columbus 2015Responsive Theme Workshop - WordCamp Columbus 2015
Responsive Theme Workshop - WordCamp Columbus 2015Joe Querin
 
Custom Post Types--Front End
Custom Post Types--Front EndCustom Post Types--Front End
Custom Post Types--Front EndBill Robbins
 
Advanced Custom Post Types
Advanced Custom Post TypesAdvanced Custom Post Types
Advanced Custom Post TypesAndy Stratton
 
Custom Post Types in Depth at WordCamp Montreal
Custom Post Types in Depth at WordCamp MontrealCustom Post Types in Depth at WordCamp Montreal
Custom Post Types in Depth at WordCamp MontrealJoey Kudish
 
Custom Post Types and Taxonomies
Custom Post Types and TaxonomiesCustom Post Types and Taxonomies
Custom Post Types and TaxonomiesTammy Hart
 
A/B Testing: Make your wildest conversion goals come true
A/B Testing: Make your wildest conversion goals come trueA/B Testing: Make your wildest conversion goals come true
A/B Testing: Make your wildest conversion goals come trueBill Robbins
 
Stepping Into Custom Post Types
Stepping Into Custom Post TypesStepping Into Custom Post Types
Stepping Into Custom Post TypesK.Adam White
 
Nate Reist WCGR WP AJAX presentation
Nate Reist WCGR WP AJAX presentationNate Reist WCGR WP AJAX presentation
Nate Reist WCGR WP AJAX presentationnatereist
 
Angular js introduction by Tania Gonzales
Angular js introduction by Tania GonzalesAngular js introduction by Tania Gonzales
Angular js introduction by Tania GonzalesThoughtworks
 
The Future of WordPress and JavaScript
The Future of WordPress and JavaScriptThe Future of WordPress and JavaScript
The Future of WordPress and JavaScriptAndrew Duthie
 
Becoming a better WordPress Developer
Becoming a better WordPress DeveloperBecoming a better WordPress Developer
Becoming a better WordPress DeveloperJoey Kudish
 
Wordpress as a Backend
Wordpress as a BackendWordpress as a Backend
Wordpress as a BackendAndrew Duthie
 
Launching a WordPress Site 101 (Cincinnati WordPress, August 2015)
Launching a WordPress Site 101 (Cincinnati WordPress, August 2015)Launching a WordPress Site 101 (Cincinnati WordPress, August 2015)
Launching a WordPress Site 101 (Cincinnati WordPress, August 2015)Andrew Duthie
 
WordPress Custom Post Types
WordPress Custom Post TypesWordPress Custom Post Types
WordPress Custom Post TypesNile Flores
 
Building a JavaScript App powered by WordPress & AngularJS
Building a JavaScript App powered by WordPress & AngularJSBuilding a JavaScript App powered by WordPress & AngularJS
Building a JavaScript App powered by WordPress & AngularJSRoy Sivan
 
Webinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST APIWebinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST APIWP Engine
 
Introduction to AngularJS For WordPress Developers
Introduction to AngularJS For WordPress DevelopersIntroduction to AngularJS For WordPress Developers
Introduction to AngularJS For WordPress DevelopersCaldera Labs
 

Viewers also liked (20)

Responsive Theme Workshop - WordCamp Columbus 2015
Responsive Theme Workshop - WordCamp Columbus 2015Responsive Theme Workshop - WordCamp Columbus 2015
Responsive Theme Workshop - WordCamp Columbus 2015
 
Custom Post Types--Front End
Custom Post Types--Front EndCustom Post Types--Front End
Custom Post Types--Front End
 
Advanced Custom Post Types
Advanced Custom Post TypesAdvanced Custom Post Types
Advanced Custom Post Types
 
Custom Post Types in Depth at WordCamp Montreal
Custom Post Types in Depth at WordCamp MontrealCustom Post Types in Depth at WordCamp Montreal
Custom Post Types in Depth at WordCamp Montreal
 
Custom Post Types and Taxonomies
Custom Post Types and TaxonomiesCustom Post Types and Taxonomies
Custom Post Types and Taxonomies
 
A/B Testing: Make your wildest conversion goals come true
A/B Testing: Make your wildest conversion goals come trueA/B Testing: Make your wildest conversion goals come true
A/B Testing: Make your wildest conversion goals come true
 
Stepping Into Custom Post Types
Stepping Into Custom Post TypesStepping Into Custom Post Types
Stepping Into Custom Post Types
 
Nate Reist WCGR WP AJAX presentation
Nate Reist WCGR WP AJAX presentationNate Reist WCGR WP AJAX presentation
Nate Reist WCGR WP AJAX presentation
 
Angular js introduction by Tania Gonzales
Angular js introduction by Tania GonzalesAngular js introduction by Tania Gonzales
Angular js introduction by Tania Gonzales
 
The Future of WordPress and JavaScript
The Future of WordPress and JavaScriptThe Future of WordPress and JavaScript
The Future of WordPress and JavaScript
 
Becoming a better WordPress Developer
Becoming a better WordPress DeveloperBecoming a better WordPress Developer
Becoming a better WordPress Developer
 
Curso AngularJS - 1. introducción
Curso AngularJS - 1. introducciónCurso AngularJS - 1. introducción
Curso AngularJS - 1. introducción
 
Wordpress as a Backend
Wordpress as a BackendWordpress as a Backend
Wordpress as a Backend
 
Launching a WordPress Site 101 (Cincinnati WordPress, August 2015)
Launching a WordPress Site 101 (Cincinnati WordPress, August 2015)Launching a WordPress Site 101 (Cincinnati WordPress, August 2015)
Launching a WordPress Site 101 (Cincinnati WordPress, August 2015)
 
WordPress Custom Post Types
WordPress Custom Post TypesWordPress Custom Post Types
WordPress Custom Post Types
 
Introducción a Angular JS
Introducción a Angular JSIntroducción a Angular JS
Introducción a Angular JS
 
Building a JavaScript App powered by WordPress & AngularJS
Building a JavaScript App powered by WordPress & AngularJSBuilding a JavaScript App powered by WordPress & AngularJS
Building a JavaScript App powered by WordPress & AngularJS
 
Webinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST APIWebinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST API
 
Angular js
Angular jsAngular js
Angular js
 
Introduction to AngularJS For WordPress Developers
Introduction to AngularJS For WordPress DevelopersIntroduction to AngularJS For WordPress Developers
Introduction to AngularJS For WordPress Developers
 

Similar to WP 201 Custom Post Types - Custom Fields - WordCamp Columbus 2015

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...Evan Mullins
 
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 FieldsJoe Querin
 
WP 101 - Custom Fields & Post Types
WP 101 - Custom Fields & Post TypesWP 101 - Custom Fields & Post Types
WP 101 - Custom Fields & Post TypesJoe Querin
 
WordPress Custom Fields: Control your content presentation by breaking out of...
WordPress Custom Fields: Control your content presentation by breaking out of...WordPress Custom Fields: Control your content presentation by breaking out of...
WordPress Custom Fields: Control your content presentation by breaking out of...Denise Williams
 
Introduction to Freelance Writing
Introduction to Freelance WritingIntroduction to Freelance Writing
Introduction to Freelance WritingLynskey
 
Introduction to Freelance Writing
Introduction to Freelance WritingIntroduction to Freelance Writing
Introduction to Freelance WritingLynskey
 
So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017
So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017 So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017
So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017 Evan Mullins
 
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!Evan Mullins
 
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...LinnAlexandra
 
Spencer Nash - Advanced Custom Fields
Spencer Nash - Advanced Custom FieldsSpencer Nash - Advanced Custom Fields
Spencer Nash - Advanced Custom Fieldsdominicj
 
WordPress HTML, CSS & Child Themes
WordPress HTML, CSS & Child ThemesWordPress HTML, CSS & Child Themes
WordPress HTML, CSS & Child ThemesMichelle Ames
 
Create and publish an optimized blog post to WordPress
Create and publish an optimized blog post to WordPressCreate and publish an optimized blog post to WordPress
Create and publish an optimized blog post to WordPressKaren Cioffi-Ventrice
 
Wordpress course
Wordpress courseWordpress course
Wordpress courseSpy Seat
 
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to DevelopmentWordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to DevelopmentEvan Mullins
 
Blogging Basics
Blogging BasicsBlogging Basics
Blogging BasicsRino Landa
 

Similar to WP 201 Custom Post Types - Custom Fields - WordCamp Columbus 2015 (20)

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...
 
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 101 - Custom Fields & Post Types
WP 101 - Custom Fields & Post TypesWP 101 - Custom Fields & Post Types
WP 101 - Custom Fields & Post Types
 
WordPress Custom Fields: Control your content presentation by breaking out of...
WordPress Custom Fields: Control your content presentation by breaking out of...WordPress Custom Fields: Control your content presentation by breaking out of...
WordPress Custom Fields: Control your content presentation by breaking out of...
 
Introduction to Freelance Writing
Introduction to Freelance WritingIntroduction to Freelance Writing
Introduction to Freelance Writing
 
Introduction to Freelance Writing
Introduction to Freelance WritingIntroduction to Freelance Writing
Introduction to Freelance Writing
 
So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017
So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017 So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017
So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017
 
SEO for WordPress Blogs
SEO for WordPress BlogsSEO for WordPress Blogs
SEO for WordPress Blogs
 
The WordPress Author
The WordPress AuthorThe WordPress Author
The WordPress Author
 
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!
 
7 steps
7 steps7 steps
7 steps
 
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
 
Spencer Nash - Advanced Custom Fields
Spencer Nash - Advanced Custom FieldsSpencer Nash - Advanced Custom Fields
Spencer Nash - Advanced Custom Fields
 
WordPress HTML, CSS & Child Themes
WordPress HTML, CSS & Child ThemesWordPress HTML, CSS & Child Themes
WordPress HTML, CSS & Child Themes
 
Create and publish an optimized blog post to WordPress
Create and publish an optimized blog post to WordPressCreate and publish an optimized blog post to WordPress
Create and publish an optimized blog post to WordPress
 
Wordpress course
Wordpress courseWordpress course
Wordpress course
 
W pthemes
W pthemesW pthemes
W pthemes
 
Blogging 101 Guide
Blogging 101 GuideBlogging 101 Guide
Blogging 101 Guide
 
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to DevelopmentWordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
 
Blogging Basics
Blogging BasicsBlogging Basics
Blogging Basics
 

More from Joe Querin

WP 101 - Local Development - Themes and Plugins
WP 101 - Local Development - Themes and PluginsWP 101 - Local Development - Themes and Plugins
WP 101 - Local Development - Themes and PluginsJoe Querin
 
WP101 - Themes and Plugins
WP101 - Themes and PluginsWP101 - Themes and Plugins
WP101 - Themes and PluginsJoe Querin
 
WP 101 - WordPress Basics
WP 101 - WordPress BasicsWP 101 - WordPress Basics
WP 101 - WordPress BasicsJoe Querin
 
WordCamp Kent 2019 - WP 101: Guten.. What?
WordCamp Kent 2019 - WP 101: Guten.. What?WordCamp Kent 2019 - WP 101: Guten.. What?
WordCamp Kent 2019 - WP 101: Guten.. What?Joe Querin
 
WordCamp Kent 2019 - WP 101: Local Development - Themes and Plugins
WordCamp Kent 2019 - WP 101: Local Development - Themes and PluginsWordCamp Kent 2019 - WP 101: Local Development - Themes and Plugins
WordCamp Kent 2019 - WP 101: Local Development - Themes and PluginsJoe Querin
 
WordCamp Kent 2019 - WP 101: Themes & Plugins: What are they, and where do I ...
WordCamp Kent 2019 - WP 101: Themes & Plugins: What are they, and where do I ...WordCamp Kent 2019 - WP 101: Themes & Plugins: What are they, and where do I ...
WordCamp Kent 2019 - WP 101: Themes & Plugins: What are they, and where do I ...Joe Querin
 
WordCamp Kent 2019 - WP 101: WordPress Basics
WordCamp Kent 2019 - WP 101: WordPress BasicsWordCamp Kent 2019 - WP 101: WordPress Basics
WordCamp Kent 2019 - WP 101: WordPress BasicsJoe Querin
 
One Plugin to Rule All Your Custom Code
One Plugin to Rule All Your Custom CodeOne Plugin to Rule All Your Custom Code
One Plugin to Rule All Your Custom CodeJoe Querin
 
Why & How to Create a WordPress Plugin
Why & How to Create a WordPress PluginWhy & How to Create a WordPress Plugin
Why & How to Create a WordPress PluginJoe Querin
 
Building a WordPress Sandbox
Building a WordPress SandboxBuilding a WordPress Sandbox
Building a WordPress SandboxJoe Querin
 
Using WordPress as a web application platform
Using WordPress as a web application platformUsing WordPress as a web application platform
Using WordPress as a web application platformJoe Querin
 
Theme development essentials columbus oh word camp 2012
Theme development essentials   columbus oh word camp 2012Theme development essentials   columbus oh word camp 2012
Theme development essentials columbus oh word camp 2012Joe Querin
 

More from Joe Querin (12)

WP 101 - Local Development - Themes and Plugins
WP 101 - Local Development - Themes and PluginsWP 101 - Local Development - Themes and Plugins
WP 101 - Local Development - Themes and Plugins
 
WP101 - Themes and Plugins
WP101 - Themes and PluginsWP101 - Themes and Plugins
WP101 - Themes and Plugins
 
WP 101 - WordPress Basics
WP 101 - WordPress BasicsWP 101 - WordPress Basics
WP 101 - WordPress Basics
 
WordCamp Kent 2019 - WP 101: Guten.. What?
WordCamp Kent 2019 - WP 101: Guten.. What?WordCamp Kent 2019 - WP 101: Guten.. What?
WordCamp Kent 2019 - WP 101: Guten.. What?
 
WordCamp Kent 2019 - WP 101: Local Development - Themes and Plugins
WordCamp Kent 2019 - WP 101: Local Development - Themes and PluginsWordCamp Kent 2019 - WP 101: Local Development - Themes and Plugins
WordCamp Kent 2019 - WP 101: Local Development - Themes and Plugins
 
WordCamp Kent 2019 - WP 101: Themes & Plugins: What are they, and where do I ...
WordCamp Kent 2019 - WP 101: Themes & Plugins: What are they, and where do I ...WordCamp Kent 2019 - WP 101: Themes & Plugins: What are they, and where do I ...
WordCamp Kent 2019 - WP 101: Themes & Plugins: What are they, and where do I ...
 
WordCamp Kent 2019 - WP 101: WordPress Basics
WordCamp Kent 2019 - WP 101: WordPress BasicsWordCamp Kent 2019 - WP 101: WordPress Basics
WordCamp Kent 2019 - WP 101: WordPress Basics
 
One Plugin to Rule All Your Custom Code
One Plugin to Rule All Your Custom CodeOne Plugin to Rule All Your Custom Code
One Plugin to Rule All Your Custom Code
 
Why & How to Create a WordPress Plugin
Why & How to Create a WordPress PluginWhy & How to Create a WordPress Plugin
Why & How to Create a WordPress Plugin
 
Building a WordPress Sandbox
Building a WordPress SandboxBuilding a WordPress Sandbox
Building a WordPress Sandbox
 
Using WordPress as a web application platform
Using WordPress as a web application platformUsing WordPress as a web application platform
Using WordPress as a web application platform
 
Theme development essentials columbus oh word camp 2012
Theme development essentials   columbus oh word camp 2012Theme development essentials   columbus oh word camp 2012
Theme development essentials columbus oh word camp 2012
 

Recently uploaded

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 DiscoveryTrustArc
 
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?Igalia
 
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 RobisonAnna Loughnan Colquhoun
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
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 educationjfdjdjcjdnsjd
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
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 Processorsdebabhi2
 
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 challengesrafiqahmad00786416
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
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...DianaGray10
 
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 REVIEWERMadyBayot
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
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...Jeffrey Haguewood
 
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 FresherRemote DBA Services
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
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...Miguel Araújo
 

Recently uploaded (20)

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
 
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?
 
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
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
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
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
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
 
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
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
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...
 
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
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
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...
 
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
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
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...
 

WP 201 Custom Post Types - Custom Fields - WordCamp Columbus 2015

  • 1. WP 201: Custom Post Types, Custom Fields WordCamp Columbus 2015 #wccbus | #wp201cp
  • 2.  Before we describe what a custom post type is, let’s review what is a post type?  In WordPress there are 5 post types.  Post – Blog Entry  Page – Static Content that doesn’t expire or change.  Attachment – Document, Image, Video, etc.  Revision – Version of a Post or Page  Navigation Menu Item  A Custom Post Type, is one that you create! What are Custom Post Types?
  • 3.  Content that needs to be structured in a certain way, and you wish to provide a template to ensure the content is always represented the same.  Examples:  Recipes  Products (non-ecommerce)  Frequently Asked Questions  etc. Why create a Custom Post Type?
  • 4. How Do I Create a Custom Post Type? add_action( 'init', 'create_post_type' ); function create_post_type() { register_post_type( 'acme_product', array( 'labels' => array( 'name' => __( 'Products' ), 'singular_name' => __( 'Product' ) ), 'public' => true, 'has_archive' => true, ) ); } Sample: https://codex.wordpress.org/Post_Types
  • 5.  Where do I put the code?  You could put the code in your themesfunctions.php file. How Do I Create a Custom Post Type?
  • 6. Example Scenario  Let’s say you have a food blog and you want to use a custom post type to display your recipes.  So you use the awesome code we just looked at, customized it to represent your menu offerings. Created categories for breakfast, lunch, dinner, appetizers, desserts.  You have populated your menu with all of your fantastic recipes.  Life is good!
  • 7. Example Scenario  Now let’s say 3 months or 6 months, or maybe even a whole year goes by, and everything is still good.  Then you find the ultimate theme, it’s great, it looks just like you want your website to look.  So you install it, then you activate it.  Then later that day or the next someone emails and asks where are your recipes, so you tell them to click on recipes, and they ask WHERE? I’m on your site and there are no recipes.
  • 8. Example Scenario  So you go to your site and check. Hmmm no menu….  Then in 3…2…1.. You panic!
  • 9.  Where do I put the code?  You could put the code in your themesfunctions.php file.  A better place would be in a plugin!  A plugin won’t cause your content to disappear.  How do I create a plugin? How Do I Create a Custom Post Type?
  • 11. What is a Custom Field?  The Codex defines a custom field as meta-data, that contains a key/value pair.  ??????
  • 12. What is a Custom Field?  Even I admit it’s pretty technical and confusing.  If you keep reading the codex page though you’ll see what a key/value pair is.  Key – the name of the meta-data  Value – the meta-data  Example:  Key: Currently Reading  Value: Calvin and Hobbes
  • 13. What can I do with a Custom Field?  You need a feature for your website, such as announcements.  First you create a custom post type to handle the announcement content.  Title  Description  Photo  It would be cool if I could make announcements appear automatically on a certain date and disappear automatically on a certain date.
  • 14. What can I do with a Custom Field?  Create a custom field  Start Date – built in scheduling of post  Display End Date  Importance  Using some PHP logic when displaying the content we can automatically display based upon the server’s date the content, as well as stop displaying it.  Using similar PHP logic, we can change the CSS class or ID of the containing element to make the announcement stand out.
  • 16. Links Mentioned  www.generatewp.com – various form based generators for code snippets in WordPress  WP Beginner – Site Specific plugin – http://www.wpbeginner.com/beginners-guide/what-why-and- how-tos-of-creating-a-site-specific-wordpress-plugin/  Recipe Custom Post Type Example – https://gist.github.com/joecue/d0a5e37f3d1bbe17ae1f  Announcement Custom Field (Meta Box) and Custom Post Type Example – https://gist.github.com/joecue/7d2339e4e9a8b16ab0a4