SlideShare ist ein Scribd-Unternehmen logo
1 von 59
Downloaden Sie, um offline zu lesen
Custom Post Types
Choose Your Own Adventure
WordCamp Atlanta 15 March 2014
Evan Mullins @circlecube
WordPress is for more than just blogging. Create and manage more types
of content, like a portfolio, events, testimonials, images, people, cats
anything you can think of you’d like to have a website about. Learn how
to add content types like they were built in.
Who am I?
I’ve been using WordPress since late 2005, that’s WP 2.0! First I knew WordPress as a
blogger, then as designer, then front-end coder and since as a theme and plug-in
developer. I’m the Interactive Director at Brand Fever, an Atlanta-based brand &
marketing agency, where I get a kick out of developing sites in WordPress every day! I
see WordPress as a flexible, user-friendly option that is nearly always the best tool for the
job. I most enjoy playing with custom fields and custom post types to create simple CMS
solutions to complex problems and making them responsive & interactive. When not
programming, I’m likely busy as a soccer coach, boy scout leader or playing with my
family: My awesome wife & our 3 boys (daughter on the way) and our lab-hound mutt. I
like pizza and chocolate.
Evan Mullins
circlecube.com
Post Types
Introducing: Post Types
WordPress can hold and display many different types of
content. A single item of such a content is generally called
a post, although post is also a specific post type.
Internally, all the post types are stored in the same place,
in the wp_posts database table, but are differentiated by a
column called post_type.
WordPress 3.0 gives you the capability to add your own
custom post types and to use them in different ways.
Posts
Posts in WordPress refer to the blog content.
Each blog post is a “post”. But all other content
is also a post. I try to distinguish by always
calling blog posts, “blog posts” or “Posts” and
using the term “post” as a more abstract term.
Pages
WordPress pages are not
time based like blog posts
but would be best located in
your main navigation.
Things like your “about”
page or your “contact”
page. Pages are posts of
post_type page.
Pages can select templates
to be used so you can
customize the layout and
you can customize the
content using custom fields.
Etc
Attachment (Post Type: 'attachment')
Revision (Post Type: 'revision')
Navigation menu (Post Type: 'nav_menu_item')
WordPress NIB - Default post types
Introducing:
Custom Post Types
Custom post types are new post types you
can create. A custom post type can be added
to WordPress via the register_post_type()
function. This function allows you to define a
new post type by its labels, supported
features, availability and other specifics.
http://codex.wordpress.org/Post_Types#Custom_Post_Types
What are they used for?
Products
Portfolio Works
Events
Testimonials
Press Releases
Movies
Books
Stars
Golf Courses
Cars
Songs
Recipes
Blocks
People
Cats
Games
etc...
http://locallylost.com/pop/about-2/
http://www.brandfeverinc.com/portfolio/
CPT
Custom post types for different types of data or
content that you’d manage in a website.
(Queue Devil’s Advocate)
But, we have that already right?
Categories, tags, post formats …
Posts, pages ...
When to use?
Formats vs Taxonomies vs CPT
Taxonomies
Taxonomy is a way to
group things together.
Built in taxonomies
are categories and
tags. But we can
create custom
taxonomies as well!
http://codex.wordpress.org/Taxonomies
Taxonomy ≠ CPT
If you just want to
organize or categorize
your content, a CPT is
not the answer. Use a
taxonomy.
Post Formats
A Post Format is a
formatting designation
made to a post. A
piece of meta
information that can
be used by a theme to
customize the
presentation (or
format) of a post.
The Post Formats
feature provides a
standardized list of
formats that are
available to all themes
that support the
feature.
http://codex.wordpress.org/Post_Formats
http://markjaquith.wordpress.com/2010/11/12/post-formats-vs-custom-post-types/
Post Formats ≠ CPT
If your aim is to just
display blog content
but display each ‘type’
of blog post differently,
you might rather use
Post Formats.
When to use?
Posts vs Pages vs CPT
(Blog) Posts
Post in WordPress is
a post type that is
typical for and most
used by blogs. Posts
are normally displayed
in a blog in reverse
chronological order.
Posts are also used
for creating the feeds.
Posts usually have
comments enabled
and contain a title and
body text. They can
be organized via
taxonomy and
formatted via Post
Formats.
Posts ≠ posts (CPT)
Blog posts belong to
the blog section of
your site. If you need
any other type of
content. You have to
create it via CPT.
Pages ≠ CPT
I hope this one is obvious.
Pages in WordPress are posts, but not part of the blog
posts or Posts. Pages can use different page templates
to display them. Pages can also be organized in a
hierarchical structure, with pages being parents to
other pages, but they normally cannot be assigned
categories and tags.
Choose Your Own
CPT come with many options/arguments:
label(s), description, public, exclude_from_search,
publicly_queryable, show_ui, show_in_nav_menu,
show_in_menu, show_in_admin_bar, menu_position,
capability_type, capabilities, map_meta_cap, hierarchical,
supports, register_meta_box_cb, taxonomies, has_archive,
permalink_epmask, rewrite, query_var, can_export.
How to
How to create a CPT : 1 of 3
Code it yourself:
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,
...
)
);
}
Program it where?
(queue debate: theme vs plugin)
Hooks
Hooks are provided by WordPress to allow you to 'hook
into' the rest of WordPress. That is, your functions hook
into WordPress functions. Then when the WordPress
functions are called at any time, it sets your code in motion.
Hooks
actions
Actions are the hooks that the WordPress
core launches at specific points during
execution, or when specific events occur.
Your plugin can specify that one or more of its
PHP functions are executed at these points,
using the Action API.
filters
Filters are the hooks that WordPress
launches to modify text of various types
before adding it to the database or sending
it to the browser screen. Your plugin can
specify that one or more of its PHP
functions is executed to modify specific
types of text at these times, using the Filter
API.
How to Create CPT: 2 of 3
Use a tool to write the
code for you.
GenerateWP.com
http://generatewp.com/post-type/
Themergency.com
http://themergency.com/generators/wordpress-custom-post-types/
How to Create CPT: 3 of 3
Use a plugin to
manage your custom
post types.
Any favorites out there?
Custom Post Type UI
http://wordpress.org/plugins/custom-post-type-ui/
Types
http://wordpress.org/plugins/types/
PIKLIST
http://wordpress.org/plugins/piklist/
WP Easy Post Types
http://wordpress.org/plugins/easy-post-types/
MasterPress
http://masterpressplugin.com/
Now What?
You’ve decided what post types you want.
You’ve decided how to add them.
Add your recipe post type.
Add all your favorite recipes as content.
Most likely though, your custom post type
needs custom content, no? A recipe has
different data than the default title + body.
And Then?
How to customize content for the custom post
type?
How to display customized content for the
custom post type?
Custom Fields
Again 3 ways:
1. Write your own.
2. Use a tool to help you write it.
3. Use a plugin.
Custom Fields: 1 of 3
Roll your own.
Use the built-in
custom fields to
add these values
to your content.
Custom Fields: 1 of 3
Custom Fields: 1 of 3
<?php the_meta(); ?>
<?php $key="mykey"; echo get_post_meta($post->ID, $key, true); ?>
Then, set up your
template files for this
custom post type to
display the fields.
Theme Template Hierarchy
Which template file(s) will WordPress use
when it displays a certain type of page?
The huge logic tree (diagram) that helps
WordPress decide which template to show
for every type of content. It shows the
defaults and fallbacks, notice how everything
defaults back to index as a fallback if that
specific type of content does not have a
template.
https://codex.wordpress.org/Template_Hierarchy
Template Files for CPTs
single-$posttype.php
single-recipe.php will
be used instead of the
default single.php file
for this CPT.
archive-$posttype.php
archive-recipe.php will
be used instead of the
default archive.php file
for this CPT.
Custom Fields: 2 of 3
Use a tool/library/generator to support/write
your code.
Custom Metaboxes and Fields for WordPress
by WebDevStudios on github
any other shout outs?
https://github.com/webdevstudios/Custom-Metaboxes-and-Fields-for-WordPress
Custom Fields: 3 of 3
Use a plugin. I recommend my all-time favorite
plugin EVER:
Advanced Custom Fields by mate Elliot
Condon
any other shout outs?
http://www.advancedcustomfields.com/ http://wordpress.org/extend/plugins/advanced-custom-fields/
<?php the_field(‘field_name’); ?>
<?php get_field(‘field_name’); ?>
Additional Reading:
http://codex.wordpress.
org/Post_Types#Custom_Post_Types
http://justintadlock.com/archives/2010/04/29/custom-post-
types-in-wordpress
http://wp.smashingmagazine.com/2012/11/08/complete-
guide-custom-post-types/
Thank You!
Any Questions?
Slides @ http://circlecube.com/wordpress/
Evan Mullins
circlecube.com

Weitere ähnliche Inhalte

Ähnlich wie Custom post types- Choose Your Own Adventure - WordCamp Atlanta 2014 - Evan Mullins

WP 201 Custom Post Types - Custom Fields - WordCamp Columbus 2015
WP 201   Custom Post Types - Custom Fields - WordCamp Columbus 2015WP 201   Custom Post Types - Custom Fields - WordCamp Columbus 2015
WP 201 Custom Post Types - Custom Fields - WordCamp Columbus 2015Joe Querin
 
Custom Post Types and Taxonomies
Custom Post Types and TaxonomiesCustom Post Types and Taxonomies
Custom Post Types and TaxonomiesTammy Hart
 
WordPress custom posts types for structured content
WordPress custom posts types for structured contentWordPress custom posts types for structured content
WordPress custom posts types for structured contentFirestorm Creative Studios
 
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 sesh2techvoltz
 
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 wordpressstimasoft
 
Stepping Into Custom Post Types
Stepping Into Custom Post TypesStepping Into Custom Post Types
Stepping Into Custom Post TypesK.Adam White
 
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
 
Introduction to WordPress Slides from WordCamp 2012 by Gary A. Bacon
Introduction to WordPress Slides from WordCamp 2012 by Gary A. BaconIntroduction to WordPress Slides from WordCamp 2012 by Gary A. Bacon
Introduction to WordPress Slides from WordCamp 2012 by Gary A. BaconGary Bacon
 
Custom WordPress theme development
Custom WordPress theme developmentCustom WordPress theme development
Custom WordPress theme developmentTammy Hart
 
The Way to Theme Enlightenment
The Way to Theme EnlightenmentThe Way to Theme Enlightenment
The Way to Theme EnlightenmentAmanda Giles
 
The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017Amanda Giles
 
Word press interview question and answer tops technologies
Word press interview question and answer   tops technologiesWord press interview question and answer   tops technologies
Word press interview question and answer tops technologiesTOPS Technologies
 
Slavin-Dodson Piece, With Code.
Slavin-Dodson Piece, With Code.Slavin-Dodson Piece, With Code.
Slavin-Dodson Piece, With Code.ALATechSource
 
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
 
An Introduction to Custom Post Types
An Introduction to Custom Post TypesAn Introduction to Custom Post Types
An Introduction to Custom Post TypesCarleton Web Services
 
What is wordpress week 1
What is wordpress week 1What is wordpress week 1
What is wordpress week 1hapy
 
WordPress 3 Custom Post Types
WordPress 3 Custom Post TypesWordPress 3 Custom Post Types
WordPress 3 Custom Post TypesDave Zille
 
Custom Post Types in WP3
Custom Post Types in WP3Custom Post Types in WP3
Custom Post Types in WP3gregghenry
 

Ähnlich wie Custom post types- Choose Your Own Adventure - WordCamp Atlanta 2014 - Evan Mullins (20)

WP 201 Custom Post Types - Custom Fields - WordCamp Columbus 2015
WP 201   Custom Post Types - Custom Fields - WordCamp Columbus 2015WP 201   Custom Post Types - Custom Fields - WordCamp Columbus 2015
WP 201 Custom Post Types - Custom Fields - WordCamp Columbus 2015
 
Custom Post Types and Taxonomies
Custom Post Types and TaxonomiesCustom Post Types and Taxonomies
Custom Post Types and Taxonomies
 
WordPress custom posts types for structured content
WordPress custom posts types for structured contentWordPress custom posts types for structured content
WordPress custom posts types for structured content
 
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
 
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
 
Stepping Into Custom Post Types
Stepping Into Custom Post TypesStepping Into Custom Post Types
Stepping Into Custom Post Types
 
Wordpress(css,php,js,ajax)
Wordpress(css,php,js,ajax)Wordpress(css,php,js,ajax)
Wordpress(css,php,js,ajax)
 
The WordPress Author
The WordPress AuthorThe WordPress Author
The WordPress Author
 
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
 
Introduction to WordPress Slides from WordCamp 2012 by Gary A. Bacon
Introduction to WordPress Slides from WordCamp 2012 by Gary A. BaconIntroduction to WordPress Slides from WordCamp 2012 by Gary A. Bacon
Introduction to WordPress Slides from WordCamp 2012 by Gary A. Bacon
 
Custom WordPress theme development
Custom WordPress theme developmentCustom WordPress theme development
Custom WordPress theme development
 
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
 
Word press interview question and answer tops technologies
Word press interview question and answer   tops technologiesWord press interview question and answer   tops technologies
Word press interview question and answer tops technologies
 
Slavin-Dodson Piece, With Code.
Slavin-Dodson Piece, With Code.Slavin-Dodson Piece, With Code.
Slavin-Dodson Piece, With Code.
 
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 ...
 
An Introduction to Custom Post Types
An Introduction to Custom Post TypesAn Introduction to Custom Post Types
An Introduction to Custom Post Types
 
What is wordpress week 1
What is wordpress week 1What is wordpress week 1
What is wordpress week 1
 
WordPress 3 Custom Post Types
WordPress 3 Custom Post TypesWordPress 3 Custom Post Types
WordPress 3 Custom Post Types
 
Custom Post Types in WP3
Custom Post Types in WP3Custom Post Types in WP3
Custom Post Types in WP3
 

Mehr von Evan Mullins

Blockity McBlock Blocks, Oh My!
Blockity McBlock Blocks, Oh My!Blockity McBlock Blocks, Oh My!
Blockity McBlock Blocks, Oh My!Evan Mullins
 
WordCamp Atlanta - April 15 2018 - dev team workflow and processes with word...
WordCamp Atlanta -  April 15 2018 - dev team workflow and processes with word...WordCamp Atlanta -  April 15 2018 - dev team workflow and processes with word...
WordCamp Atlanta - April 15 2018 - dev team workflow and processes with word...Evan Mullins
 
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
 
Meetup: The big change coming to WordPress in 2018 - Gutenberg
Meetup: The big change coming to WordPress in 2018 - GutenbergMeetup: The big change coming to WordPress in 2018 - Gutenberg
Meetup: The big change coming to WordPress in 2018 - GutenbergEvan Mullins
 
WordCamp Wilmington 2017 WP-API Why?
WordCamp Wilmington 2017   WP-API Why?WordCamp Wilmington 2017   WP-API Why?
WordCamp Wilmington 2017 WP-API Why?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
 
WordCamp Birmingham 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Birmingham 2016 - WP API, What is it good for? Absolutely Everything!WordCamp Birmingham 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Birmingham 2016 - WP API, What is it good for? Absolutely Everything!Evan Mullins
 
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!Evan Mullins
 
Modifying your themes design - Learning CSS - Atlanta WordPress users group
Modifying your themes design - Learning CSS - Atlanta WordPress users groupModifying your themes design - Learning CSS - Atlanta WordPress users group
Modifying your themes design - Learning CSS - Atlanta WordPress users groupEvan Mullins
 
Firstborn child theme word camp presentation - atlanta 2013
Firstborn child theme   word camp presentation - atlanta 2013Firstborn child theme   word camp presentation - atlanta 2013
Firstborn child theme word camp presentation - atlanta 2013Evan Mullins
 
From PSD to WP Theme
From PSD to WP ThemeFrom PSD to WP Theme
From PSD to WP ThemeEvan Mullins
 

Mehr von Evan Mullins (11)

Blockity McBlock Blocks, Oh My!
Blockity McBlock Blocks, Oh My!Blockity McBlock Blocks, Oh My!
Blockity McBlock Blocks, Oh My!
 
WordCamp Atlanta - April 15 2018 - dev team workflow and processes with word...
WordCamp Atlanta -  April 15 2018 - dev team workflow and processes with word...WordCamp Atlanta -  April 15 2018 - dev team workflow and processes with word...
WordCamp Atlanta - April 15 2018 - dev team workflow and processes with word...
 
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
 
Meetup: The big change coming to WordPress in 2018 - Gutenberg
Meetup: The big change coming to WordPress in 2018 - GutenbergMeetup: The big change coming to WordPress in 2018 - Gutenberg
Meetup: The big change coming to WordPress in 2018 - Gutenberg
 
WordCamp Wilmington 2017 WP-API Why?
WordCamp Wilmington 2017   WP-API Why?WordCamp Wilmington 2017   WP-API Why?
WordCamp Wilmington 2017 WP-API Why?
 
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!
 
WordCamp Birmingham 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Birmingham 2016 - WP API, What is it good for? Absolutely Everything!WordCamp Birmingham 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Birmingham 2016 - WP API, What is it good for? Absolutely Everything!
 
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
 
Modifying your themes design - Learning CSS - Atlanta WordPress users group
Modifying your themes design - Learning CSS - Atlanta WordPress users groupModifying your themes design - Learning CSS - Atlanta WordPress users group
Modifying your themes design - Learning CSS - Atlanta WordPress users group
 
Firstborn child theme word camp presentation - atlanta 2013
Firstborn child theme   word camp presentation - atlanta 2013Firstborn child theme   word camp presentation - atlanta 2013
Firstborn child theme word camp presentation - atlanta 2013
 
From PSD to WP Theme
From PSD to WP ThemeFrom PSD to WP Theme
From PSD to WP Theme
 

Kürzlich hochgeladen

Lucknow 💋 High Class Call Girls Lucknow 10k @ I'm VIP Independent Escorts Gir...
Lucknow 💋 High Class Call Girls Lucknow 10k @ I'm VIP Independent Escorts Gir...Lucknow 💋 High Class Call Girls Lucknow 10k @ I'm VIP Independent Escorts Gir...
Lucknow 💋 High Class Call Girls Lucknow 10k @ I'm VIP Independent Escorts Gir...anilsa9823
 
Top Rated Pune Call Girls Tingre Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Tingre Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Tingre Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Tingre Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
8377087607 Full Enjoy @24/7-CLEAN-Call Girls In Chhatarpur,
8377087607 Full Enjoy @24/7-CLEAN-Call Girls In Chhatarpur,8377087607 Full Enjoy @24/7-CLEAN-Call Girls In Chhatarpur,
8377087607 Full Enjoy @24/7-CLEAN-Call Girls In Chhatarpur,dollysharma2066
 
CALL ON ➥8923113531 🔝Call Girls Rajajipuram Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Rajajipuram Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Rajajipuram Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Rajajipuram Lucknow best sexual serviceanilsa9823
 
Independent Escorts in Lucknow (Adult Only) 👩🏽‍❤️‍💋‍👩🏼 8923113531 ♛ Escort S...
Independent Escorts in Lucknow  (Adult Only) 👩🏽‍❤️‍💋‍👩🏼 8923113531 ♛ Escort S...Independent Escorts in Lucknow  (Adult Only) 👩🏽‍❤️‍💋‍👩🏼 8923113531 ♛ Escort S...
Independent Escorts in Lucknow (Adult Only) 👩🏽‍❤️‍💋‍👩🏼 8923113531 ♛ Escort S...gurkirankumar98700
 
(KAVYA) Call Girls Humayun Nagar ✔️Just Call 7001035870✔️ HI-Fi Hyderabad Esc...
(KAVYA) Call Girls Humayun Nagar ✔️Just Call 7001035870✔️ HI-Fi Hyderabad Esc...(KAVYA) Call Girls Humayun Nagar ✔️Just Call 7001035870✔️ HI-Fi Hyderabad Esc...
(KAVYA) Call Girls Humayun Nagar ✔️Just Call 7001035870✔️ HI-Fi Hyderabad Esc...Sanjna Singh
 
CALL ON ➥8923113531 🔝Call Girls Aliganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Aliganj Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Aliganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Aliganj Lucknow best sexual serviceanilsa9823
 
文凭办理《原版美国USU学位证书》犹他州立大学毕业证制作成绩单修改
文凭办理《原版美国USU学位证书》犹他州立大学毕业证制作成绩单修改文凭办理《原版美国USU学位证书》犹他州立大学毕业证制作成绩单修改
文凭办理《原版美国USU学位证书》犹他州立大学毕业证制作成绩单修改atducpo
 
办理国外毕业证学位证《原版美国montana文凭》蒙大拿州立大学毕业证制作成绩单修改
办理国外毕业证学位证《原版美国montana文凭》蒙大拿州立大学毕业证制作成绩单修改办理国外毕业证学位证《原版美国montana文凭》蒙大拿州立大学毕业证制作成绩单修改
办理国外毕业证学位证《原版美国montana文凭》蒙大拿州立大学毕业证制作成绩单修改atducpo
 
9892124323, Call Girls in mumbai, Vashi Call Girls , Kurla Call girls
9892124323, Call Girls in mumbai, Vashi Call Girls , Kurla Call girls9892124323, Call Girls in mumbai, Vashi Call Girls , Kurla Call girls
9892124323, Call Girls in mumbai, Vashi Call Girls , Kurla Call girlsPooja Nehwal
 
Breath, Brain & Beyond_A Holistic Approach to Peak Performance.pdf
Breath, Brain & Beyond_A Holistic Approach to Peak Performance.pdfBreath, Brain & Beyond_A Holistic Approach to Peak Performance.pdf
Breath, Brain & Beyond_A Holistic Approach to Peak Performance.pdfJess Walker
 
LC_YouSaidYes_NewBelieverBookletDone.pdf
LC_YouSaidYes_NewBelieverBookletDone.pdfLC_YouSaidYes_NewBelieverBookletDone.pdf
LC_YouSaidYes_NewBelieverBookletDone.pdfpastor83
 
Call Girls In Andheri East Call US Pooja📞 9892124323 Book Hot And
Call Girls In Andheri East Call US Pooja📞 9892124323 Book Hot AndCall Girls In Andheri East Call US Pooja📞 9892124323 Book Hot And
Call Girls In Andheri East Call US Pooja📞 9892124323 Book Hot AndPooja Nehwal
 
Introducing to billionaire brain wave.pdf
Introducing to billionaire brain wave.pdfIntroducing to billionaire brain wave.pdf
Introducing to billionaire brain wave.pdfnoumannajam04
 
Understanding Relationship Anarchy: A Guide to Liberating Love | CIO Women Ma...
Understanding Relationship Anarchy: A Guide to Liberating Love | CIO Women Ma...Understanding Relationship Anarchy: A Guide to Liberating Love | CIO Women Ma...
Understanding Relationship Anarchy: A Guide to Liberating Love | CIO Women Ma...CIOWomenMagazine
 
$ Love Spells^ 💎 (310) 882-6330 in West Virginia, WV | Psychic Reading Best B...
$ Love Spells^ 💎 (310) 882-6330 in West Virginia, WV | Psychic Reading Best B...$ Love Spells^ 💎 (310) 882-6330 in West Virginia, WV | Psychic Reading Best B...
$ Love Spells^ 💎 (310) 882-6330 in West Virginia, WV | Psychic Reading Best B...PsychicRuben LoveSpells
 
CALL ON ➥8923113531 🔝Call Girls Adil Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Adil Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Adil Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Adil Nagar Lucknow best Female serviceanilsa9823
 
Call Girls Anjuna beach Mariott Resort ₰8588052666
Call Girls Anjuna beach Mariott Resort ₰8588052666Call Girls Anjuna beach Mariott Resort ₰8588052666
Call Girls Anjuna beach Mariott Resort ₰8588052666nishakur201
 
Pokemon Go... Unraveling the Conspiracy Theory
Pokemon Go... Unraveling the Conspiracy TheoryPokemon Go... Unraveling the Conspiracy Theory
Pokemon Go... Unraveling the Conspiracy Theorydrae5
 
CALL ON ➥8923113531 🔝Call Girls Mahanagar Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Mahanagar Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Mahanagar Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Mahanagar Lucknow best sexual serviceanilsa9823
 

Kürzlich hochgeladen (20)

Lucknow 💋 High Class Call Girls Lucknow 10k @ I'm VIP Independent Escorts Gir...
Lucknow 💋 High Class Call Girls Lucknow 10k @ I'm VIP Independent Escorts Gir...Lucknow 💋 High Class Call Girls Lucknow 10k @ I'm VIP Independent Escorts Gir...
Lucknow 💋 High Class Call Girls Lucknow 10k @ I'm VIP Independent Escorts Gir...
 
Top Rated Pune Call Girls Tingre Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Tingre Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Tingre Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Tingre Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
8377087607 Full Enjoy @24/7-CLEAN-Call Girls In Chhatarpur,
8377087607 Full Enjoy @24/7-CLEAN-Call Girls In Chhatarpur,8377087607 Full Enjoy @24/7-CLEAN-Call Girls In Chhatarpur,
8377087607 Full Enjoy @24/7-CLEAN-Call Girls In Chhatarpur,
 
CALL ON ➥8923113531 🔝Call Girls Rajajipuram Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Rajajipuram Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Rajajipuram Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Rajajipuram Lucknow best sexual service
 
Independent Escorts in Lucknow (Adult Only) 👩🏽‍❤️‍💋‍👩🏼 8923113531 ♛ Escort S...
Independent Escorts in Lucknow  (Adult Only) 👩🏽‍❤️‍💋‍👩🏼 8923113531 ♛ Escort S...Independent Escorts in Lucknow  (Adult Only) 👩🏽‍❤️‍💋‍👩🏼 8923113531 ♛ Escort S...
Independent Escorts in Lucknow (Adult Only) 👩🏽‍❤️‍💋‍👩🏼 8923113531 ♛ Escort S...
 
(KAVYA) Call Girls Humayun Nagar ✔️Just Call 7001035870✔️ HI-Fi Hyderabad Esc...
(KAVYA) Call Girls Humayun Nagar ✔️Just Call 7001035870✔️ HI-Fi Hyderabad Esc...(KAVYA) Call Girls Humayun Nagar ✔️Just Call 7001035870✔️ HI-Fi Hyderabad Esc...
(KAVYA) Call Girls Humayun Nagar ✔️Just Call 7001035870✔️ HI-Fi Hyderabad Esc...
 
CALL ON ➥8923113531 🔝Call Girls Aliganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Aliganj Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Aliganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Aliganj Lucknow best sexual service
 
文凭办理《原版美国USU学位证书》犹他州立大学毕业证制作成绩单修改
文凭办理《原版美国USU学位证书》犹他州立大学毕业证制作成绩单修改文凭办理《原版美国USU学位证书》犹他州立大学毕业证制作成绩单修改
文凭办理《原版美国USU学位证书》犹他州立大学毕业证制作成绩单修改
 
办理国外毕业证学位证《原版美国montana文凭》蒙大拿州立大学毕业证制作成绩单修改
办理国外毕业证学位证《原版美国montana文凭》蒙大拿州立大学毕业证制作成绩单修改办理国外毕业证学位证《原版美国montana文凭》蒙大拿州立大学毕业证制作成绩单修改
办理国外毕业证学位证《原版美国montana文凭》蒙大拿州立大学毕业证制作成绩单修改
 
9892124323, Call Girls in mumbai, Vashi Call Girls , Kurla Call girls
9892124323, Call Girls in mumbai, Vashi Call Girls , Kurla Call girls9892124323, Call Girls in mumbai, Vashi Call Girls , Kurla Call girls
9892124323, Call Girls in mumbai, Vashi Call Girls , Kurla Call girls
 
Breath, Brain & Beyond_A Holistic Approach to Peak Performance.pdf
Breath, Brain & Beyond_A Holistic Approach to Peak Performance.pdfBreath, Brain & Beyond_A Holistic Approach to Peak Performance.pdf
Breath, Brain & Beyond_A Holistic Approach to Peak Performance.pdf
 
LC_YouSaidYes_NewBelieverBookletDone.pdf
LC_YouSaidYes_NewBelieverBookletDone.pdfLC_YouSaidYes_NewBelieverBookletDone.pdf
LC_YouSaidYes_NewBelieverBookletDone.pdf
 
Call Girls In Andheri East Call US Pooja📞 9892124323 Book Hot And
Call Girls In Andheri East Call US Pooja📞 9892124323 Book Hot AndCall Girls In Andheri East Call US Pooja📞 9892124323 Book Hot And
Call Girls In Andheri East Call US Pooja📞 9892124323 Book Hot And
 
Introducing to billionaire brain wave.pdf
Introducing to billionaire brain wave.pdfIntroducing to billionaire brain wave.pdf
Introducing to billionaire brain wave.pdf
 
Understanding Relationship Anarchy: A Guide to Liberating Love | CIO Women Ma...
Understanding Relationship Anarchy: A Guide to Liberating Love | CIO Women Ma...Understanding Relationship Anarchy: A Guide to Liberating Love | CIO Women Ma...
Understanding Relationship Anarchy: A Guide to Liberating Love | CIO Women Ma...
 
$ Love Spells^ 💎 (310) 882-6330 in West Virginia, WV | Psychic Reading Best B...
$ Love Spells^ 💎 (310) 882-6330 in West Virginia, WV | Psychic Reading Best B...$ Love Spells^ 💎 (310) 882-6330 in West Virginia, WV | Psychic Reading Best B...
$ Love Spells^ 💎 (310) 882-6330 in West Virginia, WV | Psychic Reading Best B...
 
CALL ON ➥8923113531 🔝Call Girls Adil Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Adil Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Adil Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Adil Nagar Lucknow best Female service
 
Call Girls Anjuna beach Mariott Resort ₰8588052666
Call Girls Anjuna beach Mariott Resort ₰8588052666Call Girls Anjuna beach Mariott Resort ₰8588052666
Call Girls Anjuna beach Mariott Resort ₰8588052666
 
Pokemon Go... Unraveling the Conspiracy Theory
Pokemon Go... Unraveling the Conspiracy TheoryPokemon Go... Unraveling the Conspiracy Theory
Pokemon Go... Unraveling the Conspiracy Theory
 
CALL ON ➥8923113531 🔝Call Girls Mahanagar Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Mahanagar Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Mahanagar Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Mahanagar Lucknow best sexual service
 

Custom post types- Choose Your Own Adventure - WordCamp Atlanta 2014 - Evan Mullins

  • 1. Custom Post Types Choose Your Own Adventure WordCamp Atlanta 15 March 2014 Evan Mullins @circlecube WordPress is for more than just blogging. Create and manage more types of content, like a portfolio, events, testimonials, images, people, cats anything you can think of you’d like to have a website about. Learn how to add content types like they were built in.
  • 2. Who am I? I’ve been using WordPress since late 2005, that’s WP 2.0! First I knew WordPress as a blogger, then as designer, then front-end coder and since as a theme and plug-in developer. I’m the Interactive Director at Brand Fever, an Atlanta-based brand & marketing agency, where I get a kick out of developing sites in WordPress every day! I see WordPress as a flexible, user-friendly option that is nearly always the best tool for the job. I most enjoy playing with custom fields and custom post types to create simple CMS solutions to complex problems and making them responsive & interactive. When not programming, I’m likely busy as a soccer coach, boy scout leader or playing with my family: My awesome wife & our 3 boys (daughter on the way) and our lab-hound mutt. I like pizza and chocolate. Evan Mullins circlecube.com
  • 4. Introducing: Post Types WordPress can hold and display many different types of content. A single item of such a content is generally called a post, although post is also a specific post type. Internally, all the post types are stored in the same place, in the wp_posts database table, but are differentiated by a column called post_type. WordPress 3.0 gives you the capability to add your own custom post types and to use them in different ways.
  • 5. Posts Posts in WordPress refer to the blog content. Each blog post is a “post”. But all other content is also a post. I try to distinguish by always calling blog posts, “blog posts” or “Posts” and using the term “post” as a more abstract term.
  • 6. Pages WordPress pages are not time based like blog posts but would be best located in your main navigation. Things like your “about” page or your “contact” page. Pages are posts of post_type page. Pages can select templates to be used so you can customize the layout and you can customize the content using custom fields.
  • 7. Etc Attachment (Post Type: 'attachment') Revision (Post Type: 'revision') Navigation menu (Post Type: 'nav_menu_item')
  • 8. WordPress NIB - Default post types
  • 9. Introducing: Custom Post Types Custom post types are new post types you can create. A custom post type can be added to WordPress via the register_post_type() function. This function allows you to define a new post type by its labels, supported features, availability and other specifics. http://codex.wordpress.org/Post_Types#Custom_Post_Types
  • 10. What are they used for? Products Portfolio Works Events Testimonials Press Releases Movies Books Stars Golf Courses Cars Songs Recipes Blocks People Cats Games etc...
  • 13.
  • 14. CPT Custom post types for different types of data or content that you’d manage in a website. (Queue Devil’s Advocate) But, we have that already right? Categories, tags, post formats … Posts, pages ...
  • 15. When to use? Formats vs Taxonomies vs CPT
  • 16. Taxonomies Taxonomy is a way to group things together. Built in taxonomies are categories and tags. But we can create custom taxonomies as well! http://codex.wordpress.org/Taxonomies
  • 17. Taxonomy ≠ CPT If you just want to organize or categorize your content, a CPT is not the answer. Use a taxonomy.
  • 18. Post Formats A Post Format is a formatting designation made to a post. A piece of meta information that can be used by a theme to customize the presentation (or format) of a post. The Post Formats feature provides a standardized list of formats that are available to all themes that support the feature. http://codex.wordpress.org/Post_Formats http://markjaquith.wordpress.com/2010/11/12/post-formats-vs-custom-post-types/
  • 19. Post Formats ≠ CPT If your aim is to just display blog content but display each ‘type’ of blog post differently, you might rather use Post Formats.
  • 20. When to use? Posts vs Pages vs CPT
  • 21. (Blog) Posts Post in WordPress is a post type that is typical for and most used by blogs. Posts are normally displayed in a blog in reverse chronological order. Posts are also used for creating the feeds. Posts usually have comments enabled and contain a title and body text. They can be organized via taxonomy and formatted via Post Formats.
  • 22. Posts ≠ posts (CPT) Blog posts belong to the blog section of your site. If you need any other type of content. You have to create it via CPT.
  • 23. Pages ≠ CPT I hope this one is obvious. Pages in WordPress are posts, but not part of the blog posts or Posts. Pages can use different page templates to display them. Pages can also be organized in a hierarchical structure, with pages being parents to other pages, but they normally cannot be assigned categories and tags.
  • 24. Choose Your Own CPT come with many options/arguments: label(s), description, public, exclude_from_search, publicly_queryable, show_ui, show_in_nav_menu, show_in_menu, show_in_admin_bar, menu_position, capability_type, capabilities, map_meta_cap, hierarchical, supports, register_meta_box_cb, taxonomies, has_archive, permalink_epmask, rewrite, query_var, can_export.
  • 26. How to create a CPT : 1 of 3 Code it yourself: 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, ... ) ); }
  • 27. Program it where? (queue debate: theme vs plugin)
  • 28. Hooks Hooks are provided by WordPress to allow you to 'hook into' the rest of WordPress. That is, your functions hook into WordPress functions. Then when the WordPress functions are called at any time, it sets your code in motion.
  • 29. Hooks actions Actions are the hooks that the WordPress core launches at specific points during execution, or when specific events occur. Your plugin can specify that one or more of its PHP functions are executed at these points, using the Action API. filters Filters are the hooks that WordPress launches to modify text of various types before adding it to the database or sending it to the browser screen. Your plugin can specify that one or more of its PHP functions is executed to modify specific types of text at these times, using the Filter API.
  • 30. How to Create CPT: 2 of 3 Use a tool to write the code for you.
  • 33. How to Create CPT: 3 of 3 Use a plugin to manage your custom post types. Any favorites out there?
  • 34. Custom Post Type UI http://wordpress.org/plugins/custom-post-type-ui/
  • 37. WP Easy Post Types http://wordpress.org/plugins/easy-post-types/
  • 39. Now What? You’ve decided what post types you want. You’ve decided how to add them. Add your recipe post type. Add all your favorite recipes as content. Most likely though, your custom post type needs custom content, no? A recipe has different data than the default title + body.
  • 40. And Then? How to customize content for the custom post type? How to display customized content for the custom post type?
  • 41. Custom Fields Again 3 ways: 1. Write your own. 2. Use a tool to help you write it. 3. Use a plugin.
  • 42. Custom Fields: 1 of 3 Roll your own. Use the built-in custom fields to add these values to your content.
  • 44. Custom Fields: 1 of 3 <?php the_meta(); ?> <?php $key="mykey"; echo get_post_meta($post->ID, $key, true); ?> Then, set up your template files for this custom post type to display the fields.
  • 45. Theme Template Hierarchy Which template file(s) will WordPress use when it displays a certain type of page? The huge logic tree (diagram) that helps WordPress decide which template to show for every type of content. It shows the defaults and fallbacks, notice how everything defaults back to index as a fallback if that specific type of content does not have a template.
  • 47. Template Files for CPTs single-$posttype.php single-recipe.php will be used instead of the default single.php file for this CPT. archive-$posttype.php archive-recipe.php will be used instead of the default archive.php file for this CPT.
  • 48. Custom Fields: 2 of 3 Use a tool/library/generator to support/write your code. Custom Metaboxes and Fields for WordPress by WebDevStudios on github any other shout outs?
  • 50.
  • 51. Custom Fields: 3 of 3 Use a plugin. I recommend my all-time favorite plugin EVER: Advanced Custom Fields by mate Elliot Condon any other shout outs?
  • 53.
  • 54.
  • 55.
  • 56. <?php the_field(‘field_name’); ?> <?php get_field(‘field_name’); ?>
  • 57.
  • 59. Thank You! Any Questions? Slides @ http://circlecube.com/wordpress/ Evan Mullins circlecube.com