SlideShare una empresa de Scribd logo
1 de 18
Custom Post Types
       What, Why, and How
  Heather Acton | WordCamp Detroit 2011 | 11.13.2011
Intro
• “Ex” Mechanical Engineer turned
  WordPress developer
• Started ActonWeb in 2009 by accident
• Organizer of WordCamp Chicago,
  extended into monthly meetup with 2
  chapters (so far)
• Recently co-founded Lake County
  Branding
                                Heather Acton / @heatheracton78
Overview



• What are CPTs?
• Why use CPTs?
• Common applications
• How to implement CPTs


                          Heather Acton / @heatheracton78
What are CPTs?

• Just another WordPress post
• Stored in same table (wp_posts) as WP
  default posts


Custom Post Types are NOT:
• Post Formats (see Mark Jacquith’s post)

                                  Heather Acton / @heatheracton78
Why use CPTs?


• Vary the display of the single post and
  post archives vs. WP default posts
• Simplify entry of detailed post
  information for the site owner



                                    Heather Acton / @heatheracton78
Default New Post




              Heather Acton / @heatheracton78
New Custom Post Type
w/ Custom Meta Boxes




                Heather Acton / @heatheracton78
Common Applications

• E-commerce products
• Directories
• Events
• Movie / book reviews
• Recipes
• Portfolio items

                         Heather Acton / @heatheracton78
How to Implement CPTs
      (AKA the most important slide)

   1. Register your custom post type
   2. Register any custom taxonomies
   3. Add custom meta boxes to Edit Post screen
      (prettier custom fields)
   4. Set up archives page template
   5. Set up single post template

Resource: Slides, Child Theme, & Snippets
                                        Heather Acton / @heatheracton78
Step 1:
     Register Your CPT




• Use Custom Post Type UI plugin




                                   Heather Acton / @heatheracton78
Step 2:
Register Custom Taxonomies




 • Use Custom Post Type UI plugin




                                    Heather Acton / @heatheracton78
Step 3:
Add Custom Meta Boxes



• Use Advanced Custom Fields plugin
• Use Meta Box plugin




                                      Heather Acton / @heatheracton78
Heather Acton / @heatheracton78


           Step 4:
Set Up CPT Archives Template
  •   Copy the contents of your main theme’s archives.php file in your theme
      folder

  •   Create a new file in your child theme called archives-yourcptname.php
      and paste the contents into that file

  •   Add <?php /* Template Name: YOURCPTNAME Archive */ ?> to the top of your new
      archives file

  •   Right before the loop in your new archives file, paste:
      <?php $loop = new WP_Query( array( 'post_type' => 'yourcptname', 'posts_per_page' => 10 ) ); ?>


  •   Change the loop statement to:
      <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>


  •   Create a new page via your WordPress dashboard, fill in the title with
      your desired page title, and select “YOURCPTNAME Archive” as your
      page template

  •   Once you have published posts of your custom post type, visit http://
      yoursitename.com/yourcptname to see your working CPT archive page
Notes on Creating
   CPT Archive Template

• These steps will provide the same archive
  display as your standard post archives
• Add additional parameters to the array to
  display posts in a certain order, display number
  of posts per page, etc.
• Theme frameworks that alter WP core functions
  alter this process


                                         Heather Acton / @heatheracton78
Step 5:
Set Up Single Post Template
 • Copy the contents of your current single.php
   file in your main theme folder
 • Create a new file called single-yourcptname.php
   in your child theme folder and paste the
   contents into that file
 • Replace the part of the loop that calls for the
   content and comments with calls for your
   custom fields that you generated
 • Meta-box plugin has great support on how to
   call each type of custom field
                                            Heather Acton / @heatheracton78
Bonus Step:
Celebrate Your New Superpower




                       Heather Acton / @heatheracton78
Watchouts

• Naming best practices for CPTs (see Codex)
• Theme frameworks that alter WP core functions
  (Genesis)
• Custom taxonomy names that conflict with
  your CPT names or other taxonomy names (i.e.
  your categories/tags)
     • see this forum post

                                       Heather Acton / @heatheracton78
Additional Resources
•   Slides, Child Theme, & Snippets
•   WordPress Codex | Post Types
•   Custom Post Types in WP by Justin Tadlock
•   WordPress Custom Post Types Guide
• Genesis Specific
    • Custom Post Types with Genesis
    • How to Create a Custom Template in
      Genesis
    • StudioPress forums               Heather Acton / @heatheracton78

Más contenido relacionado

La actualidad más candente

Keeping Your Themes and Plugins Organized.
Keeping Your Themes and Plugins Organized.Keeping Your Themes and Plugins Organized.
Keeping Your Themes and Plugins Organized.Jacob Martella
 
There's No Crying In Wordpress! (an intro to WP)
There's No Crying In Wordpress! (an intro to WP)There's No Crying In Wordpress! (an intro to WP)
There's No Crying In Wordpress! (an intro to WP)Grace Solivan
 
Intro To WordPress Themes
Intro To WordPress ThemesIntro To WordPress Themes
Intro To WordPress Themesdamonsharp
 
Wordcamp 2010 Themes for Beginners
Wordcamp 2010 Themes for BeginnersWordcamp 2010 Themes for Beginners
Wordcamp 2010 Themes for BeginnersBonnie Vasko
 
Making Your Own URL Shortening Service
Making Your Own URL Shortening ServiceMaking Your Own URL Shortening Service
Making Your Own URL Shortening ServiceBob Hazlett
 
WordPress Theme Workshop: Part 1
WordPress Theme Workshop: Part 1WordPress Theme Workshop: Part 1
WordPress Theme Workshop: Part 1David Bisset
 
Wordpress Tech Talk at Atlogys
Wordpress Tech Talk at AtlogysWordpress Tech Talk at Atlogys
Wordpress Tech Talk at AtlogysRitika Garga
 
Writing a WordPress Theme - HighEdWeb 2013 #WRK2
Writing a WordPress Theme - HighEdWeb 2013 #WRK2Writing a WordPress Theme - HighEdWeb 2013 #WRK2
Writing a WordPress Theme - HighEdWeb 2013 #WRK2Curtiss Grymala
 
Joomla! Installation
Joomla! InstallationJoomla! Installation
Joomla! Installationghessler
 
Building on the Microsoft Graph: App in 60 minutes
Building on the Microsoft Graph: App in 60 minutesBuilding on the Microsoft Graph: App in 60 minutes
Building on the Microsoft Graph: App in 60 minutesSPC Adriatics
 
Taking WordPress as a CMS, to the Limit
Taking WordPress as a CMS, to the LimitTaking WordPress as a CMS, to the Limit
Taking WordPress as a CMS, to the LimitJosh Guffey
 
Installing WordPress The Right Way
Installing WordPress The Right WayInstalling WordPress The Right Way
Installing WordPress The Right WayChris Burgess
 

La actualidad más candente (13)

Keeping Your Themes and Plugins Organized.
Keeping Your Themes and Plugins Organized.Keeping Your Themes and Plugins Organized.
Keeping Your Themes and Plugins Organized.
 
There's No Crying In Wordpress! (an intro to WP)
There's No Crying In Wordpress! (an intro to WP)There's No Crying In Wordpress! (an intro to WP)
There's No Crying In Wordpress! (an intro to WP)
 
Intro To WordPress Themes
Intro To WordPress ThemesIntro To WordPress Themes
Intro To WordPress Themes
 
Wordcamp 2010
Wordcamp 2010Wordcamp 2010
Wordcamp 2010
 
Wordcamp 2010 Themes for Beginners
Wordcamp 2010 Themes for BeginnersWordcamp 2010 Themes for Beginners
Wordcamp 2010 Themes for Beginners
 
Making Your Own URL Shortening Service
Making Your Own URL Shortening ServiceMaking Your Own URL Shortening Service
Making Your Own URL Shortening Service
 
WordPress Theme Workshop: Part 1
WordPress Theme Workshop: Part 1WordPress Theme Workshop: Part 1
WordPress Theme Workshop: Part 1
 
Wordpress Tech Talk at Atlogys
Wordpress Tech Talk at AtlogysWordpress Tech Talk at Atlogys
Wordpress Tech Talk at Atlogys
 
Writing a WordPress Theme - HighEdWeb 2013 #WRK2
Writing a WordPress Theme - HighEdWeb 2013 #WRK2Writing a WordPress Theme - HighEdWeb 2013 #WRK2
Writing a WordPress Theme - HighEdWeb 2013 #WRK2
 
Joomla! Installation
Joomla! InstallationJoomla! Installation
Joomla! Installation
 
Building on the Microsoft Graph: App in 60 minutes
Building on the Microsoft Graph: App in 60 minutesBuilding on the Microsoft Graph: App in 60 minutes
Building on the Microsoft Graph: App in 60 minutes
 
Taking WordPress as a CMS, to the Limit
Taking WordPress as a CMS, to the LimitTaking WordPress as a CMS, to the Limit
Taking WordPress as a CMS, to the Limit
 
Installing WordPress The Right Way
Installing WordPress The Right WayInstalling WordPress The Right Way
Installing WordPress The Right Way
 

Similar a CPT How To Guide

Starting WordPress Theme Review
Starting WordPress Theme ReviewStarting WordPress Theme Review
Starting WordPress Theme ReviewCatch Themes
 
Equity WordPress framework with Chad and Dave
Equity WordPress framework with Chad and DaveEquity WordPress framework with Chad and Dave
Equity WordPress framework with Chad and DaveIDX Broker
 
Content-Driven WordPress Development - WordCamp Omaha 2014
Content-Driven WordPress Development - WordCamp Omaha 2014Content-Driven WordPress Development - WordCamp Omaha 2014
Content-Driven WordPress Development - WordCamp Omaha 2014Stephanie Eckles
 
Workshop: Creating your first WordPress plugin
Workshop: Creating your first WordPress pluginWorkshop: Creating your first WordPress plugin
Workshop: Creating your first WordPress pluginylefebvre
 
The Flexibility of WordPress
The Flexibility of WordPressThe Flexibility of WordPress
The Flexibility of WordPressStephanie Eckles
 
The WordPress University 2012
The WordPress University 2012The WordPress University 2012
The WordPress University 2012Stephanie Leary
 
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
 
Stepping Into Custom Post Types
Stepping Into Custom Post TypesStepping Into Custom Post Types
Stepping Into Custom Post TypesK.Adam White
 
Theming in WordPress - Where do I Start?
Theming in WordPress - Where do I Start?Theming in WordPress - Where do I Start?
Theming in WordPress - Where do I Start?Edmund Turbin
 
Week 5 open session
Week 5 open sessionWeek 5 open session
Week 5 open sessionRandall Rode
 
Responsive themeworkshop wcneo2016
Responsive themeworkshop wcneo2016Responsive themeworkshop wcneo2016
Responsive themeworkshop wcneo2016David Brattoli
 
Newbies guide to customizing word press themes 25
Newbies guide to customizing word press themes 25Newbies guide to customizing word press themes 25
Newbies guide to customizing word press themes 25New Tricks
 
Wordpress theme development
Wordpress theme developmentWordpress theme development
Wordpress theme developmentNaeem Junejo
 
Custom post types - WordPress
Custom post types - WordPressCustom post types - WordPress
Custom post types - WordPresskeithdevon
 
Using Custom Post Types and Advanced Custom Fields with Elementor
 Using Custom Post Types and Advanced Custom Fields with Elementor Using Custom Post Types and Advanced Custom Fields with Elementor
Using Custom Post Types and Advanced Custom Fields with ElementorAngela Bowman
 
WordPress - Open Source Overview Presentation
WordPress - Open Source Overview PresentationWordPress - Open Source Overview Presentation
WordPress - Open Source Overview PresentationAndy Stratton
 
The Genesis Framework: Hooks & Filters for Theme Development
The Genesis Framework: Hooks & Filters for Theme DevelopmentThe Genesis Framework: Hooks & Filters for Theme Development
The Genesis Framework: Hooks & Filters for Theme DevelopmentSarah Moyer
 

Similar a CPT How To Guide (20)

Starting WordPress Theme Review
Starting WordPress Theme ReviewStarting WordPress Theme Review
Starting WordPress Theme Review
 
Equity WordPress framework with Chad and Dave
Equity WordPress framework with Chad and DaveEquity WordPress framework with Chad and Dave
Equity WordPress framework with Chad and Dave
 
Content-Driven WordPress Development - WordCamp Omaha 2014
Content-Driven WordPress Development - WordCamp Omaha 2014Content-Driven WordPress Development - WordCamp Omaha 2014
Content-Driven WordPress Development - WordCamp Omaha 2014
 
Workshop: Creating your first WordPress plugin
Workshop: Creating your first WordPress pluginWorkshop: Creating your first WordPress plugin
Workshop: Creating your first WordPress plugin
 
The Flexibility of WordPress
The Flexibility of WordPressThe Flexibility of WordPress
The Flexibility of WordPress
 
The WordPress University 2012
The WordPress University 2012The WordPress University 2012
The WordPress University 2012
 
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
 
Stepping Into Custom Post Types
Stepping Into Custom Post TypesStepping Into Custom Post Types
Stepping Into Custom Post Types
 
Theming in WordPress - Where do I Start?
Theming in WordPress - Where do I Start?Theming in WordPress - Where do I Start?
Theming in WordPress - Where do I Start?
 
Week 5 open session
Week 5 open sessionWeek 5 open session
Week 5 open session
 
Responsive themeworkshop wcneo2016
Responsive themeworkshop wcneo2016Responsive themeworkshop wcneo2016
Responsive themeworkshop wcneo2016
 
Newbies guide to customizing word press themes 25
Newbies guide to customizing word press themes 25Newbies guide to customizing word press themes 25
Newbies guide to customizing word press themes 25
 
MDST 3703 F10 Studio 10
MDST 3703 F10 Studio 10MDST 3703 F10 Studio 10
MDST 3703 F10 Studio 10
 
Wordpress theme development
Wordpress theme developmentWordpress theme development
Wordpress theme development
 
Custom post types - WordPress
Custom post types - WordPressCustom post types - WordPress
Custom post types - WordPress
 
Using Custom Post Types and Advanced Custom Fields with Elementor
 Using Custom Post Types and Advanced Custom Fields with Elementor Using Custom Post Types and Advanced Custom Fields with Elementor
Using Custom Post Types and Advanced Custom Fields with Elementor
 
WordPress - Open Source Overview Presentation
WordPress - Open Source Overview PresentationWordPress - Open Source Overview Presentation
WordPress - Open Source Overview Presentation
 
The Genesis Framework: Hooks & Filters for Theme Development
The Genesis Framework: Hooks & Filters for Theme DevelopmentThe Genesis Framework: Hooks & Filters for Theme Development
The Genesis Framework: Hooks & Filters for Theme Development
 
WordPress Complete Tutorial
WordPress Complete TutorialWordPress Complete Tutorial
WordPress Complete Tutorial
 
เพาเวอร์พอย Wordpress3 5-1
เพาเวอร์พอย Wordpress3 5-1เพาเวอร์พอย Wordpress3 5-1
เพาเวอร์พอย Wordpress3 5-1
 

Más de Heather Acton

Framework Overview - Genesis
Framework Overview - GenesisFramework Overview - Genesis
Framework Overview - GenesisHeather Acton
 
Developing a Website with WordPress
Developing a Website with WordPressDeveloping a Website with WordPress
Developing a Website with WordPressHeather Acton
 
WordPress Crash Course
WordPress Crash CourseWordPress Crash Course
WordPress Crash CourseHeather Acton
 
WordPress Crash Course - WP 101
WordPress Crash Course - WP  101WordPress Crash Course - WP  101
WordPress Crash Course - WP 101Heather Acton
 
The Digital Eco System
The Digital Eco SystemThe Digital Eco System
The Digital Eco SystemHeather Acton
 
How To Be a Nonprofit Social Media Rockstar
How To Be a Nonprofit Social Media RockstarHow To Be a Nonprofit Social Media Rockstar
How To Be a Nonprofit Social Media RockstarHeather Acton
 
Nonprofits - Get Your Blog On!
Nonprofits - Get Your Blog On!Nonprofits - Get Your Blog On!
Nonprofits - Get Your Blog On!Heather Acton
 

Más de Heather Acton (7)

Framework Overview - Genesis
Framework Overview - GenesisFramework Overview - Genesis
Framework Overview - Genesis
 
Developing a Website with WordPress
Developing a Website with WordPressDeveloping a Website with WordPress
Developing a Website with WordPress
 
WordPress Crash Course
WordPress Crash CourseWordPress Crash Course
WordPress Crash Course
 
WordPress Crash Course - WP 101
WordPress Crash Course - WP  101WordPress Crash Course - WP  101
WordPress Crash Course - WP 101
 
The Digital Eco System
The Digital Eco SystemThe Digital Eco System
The Digital Eco System
 
How To Be a Nonprofit Social Media Rockstar
How To Be a Nonprofit Social Media RockstarHow To Be a Nonprofit Social Media Rockstar
How To Be a Nonprofit Social Media Rockstar
 
Nonprofits - Get Your Blog On!
Nonprofits - Get Your Blog On!Nonprofits - Get Your Blog On!
Nonprofits - Get Your Blog On!
 

Último

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
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 MenDelhi Call girls
 
[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.pdfhans926745
 
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 Servicegiselly40
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
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 slidevu2urc
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
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.pdfUK Journal
 
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
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
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...Igalia
 
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 interpreternaman860154
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
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 2024The Digital Insurer
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 

Último (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
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
 
[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
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 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
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
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
 
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)
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
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...
 
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
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
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
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

CPT How To Guide

  • 1. Custom Post Types What, Why, and How Heather Acton | WordCamp Detroit 2011 | 11.13.2011
  • 2. Intro • “Ex” Mechanical Engineer turned WordPress developer • Started ActonWeb in 2009 by accident • Organizer of WordCamp Chicago, extended into monthly meetup with 2 chapters (so far) • Recently co-founded Lake County Branding Heather Acton / @heatheracton78
  • 3. Overview • What are CPTs? • Why use CPTs? • Common applications • How to implement CPTs Heather Acton / @heatheracton78
  • 4. What are CPTs? • Just another WordPress post • Stored in same table (wp_posts) as WP default posts Custom Post Types are NOT: • Post Formats (see Mark Jacquith’s post) Heather Acton / @heatheracton78
  • 5. Why use CPTs? • Vary the display of the single post and post archives vs. WP default posts • Simplify entry of detailed post information for the site owner Heather Acton / @heatheracton78
  • 6. Default New Post Heather Acton / @heatheracton78
  • 7. New Custom Post Type w/ Custom Meta Boxes Heather Acton / @heatheracton78
  • 8. Common Applications • E-commerce products • Directories • Events • Movie / book reviews • Recipes • Portfolio items Heather Acton / @heatheracton78
  • 9. How to Implement CPTs (AKA the most important slide) 1. Register your custom post type 2. Register any custom taxonomies 3. Add custom meta boxes to Edit Post screen (prettier custom fields) 4. Set up archives page template 5. Set up single post template Resource: Slides, Child Theme, & Snippets Heather Acton / @heatheracton78
  • 10. Step 1: Register Your CPT • Use Custom Post Type UI plugin Heather Acton / @heatheracton78
  • 11. Step 2: Register Custom Taxonomies • Use Custom Post Type UI plugin Heather Acton / @heatheracton78
  • 12. Step 3: Add Custom Meta Boxes • Use Advanced Custom Fields plugin • Use Meta Box plugin Heather Acton / @heatheracton78
  • 13. Heather Acton / @heatheracton78 Step 4: Set Up CPT Archives Template • Copy the contents of your main theme’s archives.php file in your theme folder • Create a new file in your child theme called archives-yourcptname.php and paste the contents into that file • Add <?php /* Template Name: YOURCPTNAME Archive */ ?> to the top of your new archives file • Right before the loop in your new archives file, paste: <?php $loop = new WP_Query( array( 'post_type' => 'yourcptname', 'posts_per_page' => 10 ) ); ?> • Change the loop statement to: <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> • Create a new page via your WordPress dashboard, fill in the title with your desired page title, and select “YOURCPTNAME Archive” as your page template • Once you have published posts of your custom post type, visit http:// yoursitename.com/yourcptname to see your working CPT archive page
  • 14. Notes on Creating CPT Archive Template • These steps will provide the same archive display as your standard post archives • Add additional parameters to the array to display posts in a certain order, display number of posts per page, etc. • Theme frameworks that alter WP core functions alter this process Heather Acton / @heatheracton78
  • 15. Step 5: Set Up Single Post Template • Copy the contents of your current single.php file in your main theme folder • Create a new file called single-yourcptname.php in your child theme folder and paste the contents into that file • Replace the part of the loop that calls for the content and comments with calls for your custom fields that you generated • Meta-box plugin has great support on how to call each type of custom field Heather Acton / @heatheracton78
  • 16. Bonus Step: Celebrate Your New Superpower Heather Acton / @heatheracton78
  • 17. Watchouts • Naming best practices for CPTs (see Codex) • Theme frameworks that alter WP core functions (Genesis) • Custom taxonomy names that conflict with your CPT names or other taxonomy names (i.e. your categories/tags) • see this forum post Heather Acton / @heatheracton78
  • 18. Additional Resources • Slides, Child Theme, & Snippets • WordPress Codex | Post Types • Custom Post Types in WP by Justin Tadlock • WordPress Custom Post Types Guide • Genesis Specific • Custom Post Types with Genesis • How to Create a Custom Template in Genesis • StudioPress forums Heather Acton / @heatheracton78

Notas del editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n