SlideShare a Scribd company logo
1 of 28
1




          Custom Post Types
                 Now What?
                           By Cody Helgeson
                      WordCamp Phoenix 2012




    @codyhelgeson | @fallingupmedia | #wcphx
2




    Find More Info

     Who Am I?
     My Experience with WordPress

     @codyhelgeson
     @fallingupmedia
     fallingupmedia.com
     cody@fallingupmedia.com




           @codyhelgeson | @fallingupmedia | #wcphx
3




    Topics For The Day
     • Custom Post Type Best Practices
     • Custom Taxonomies
     • Page Templates
     • Custom Fields
     • Custom Admin Columns
     • Custom Queries




           @codyhelgeson | @fallingupmedia | #wcphx
4




    Custom Post Types

     • Who has or is about to use custom post types?
     • Why use custom post types
     • Why not?
     • For the client
     • For the developer




            @codyhelgeson | @fallingupmedia | #wcphx
5




    Custom Post Types
    Examples

     • Book and Product Reviews
     • Job and Business Listings
     • Events and Locations
     • Portfolios and Case Studies
     • Combine with BuddyPress for Community Domination!
     • Anything your Heart Desires....



            @codyhelgeson | @fallingupmedia | #wcphx
6




     Custom Post Types
     The Code

    http://codex.wordpress.org/Function_Reference/register_post_type

        • Contextual help menus are a nice touch
        • Permalinks matter!
        • Flush the rewrite rules, or save permalink settings
        • /%category%/%postname%/
        • www.domain.com/custom-post-type/post-title



               @codyhelgeson | @fallingupmedia | #wcphx
7




    Topics For The Day

     • Custom Post Type Best Practices
     • Custom Taxonomies
     • Page Templates
     • Custom Fields
     • Custom Admin Columns
     • Custom Queries



           @codyhelgeson | @fallingupmedia | #wcphx
8




    Custom Taxonomies

             http://codex.wordpress.org/Taxonomies


     • Categorizes and groups content
     • Hierarchal or not? I.E. tags or categories
     • Clean and intuitive for users
     • Custom slugs argument
     • Create custom page templates and queries


            @codyhelgeson | @fallingupmedia | #wcphx
9




     Custom Taxonomies
     The Code

    http://codex.wordpress.org/Function_Reference/register_taxonomy

        • Flush rewrite or save permalink settings
        • There are reserved terms!
        • register_taxonomy($taxonomy, $object_type, $args); 




               @codyhelgeson | @fallingupmedia | #wcphx
10




     Topics For The Day
     Custom Post Types

       • Custom Post Type Best Practices
       • Custom Taxonomies
       • Page Templates
       • Custom Fields
       • Custom Admin Columns
       • Custom Queries



             @codyhelgeson | @fallingupmedia | #wcphx
11




     Page Templates
          http://codex.wordpress.org/Template_Hierarchy


      • WordPress makes it easy! Use them!
      • single-post_type.php
      • archive-post_type.php
      • taxonomy-taxonomy_name-slug.php
      • taxonomy-taxonomy_name.php


            @codyhelgeson | @fallingupmedia | #wcphx
12




     Topics For The Day
     Custom Post Types

       • Custom Post Type Best Practices
       • Custom Taxonomies
       • Page Templates
       • Custom Fields
       • Custom Admin Columns
       • Custom Queries



             @codyhelgeson | @fallingupmedia | #wcphx
13




     Custom Fields
             http://codex.wordpress.org/Custom_Fields


      • Purely incredible! Endless possibilities
      • Remove what you don’t need from editor. Take the time
      • Create your own or use a plugin
        • Advanced Custom Fields plugin
        • Magic Fields plugin
      • get_post_meta - add_post_meta

             @codyhelgeson | @fallingupmedia | #wcphx
14




     Custom Fields
     Examples



        • Real world examples on the web......




            @codyhelgeson | @fallingupmedia | #wcphx
15




     Topics For The Day
     Custom Post Types

       • Custom Post Type Best Practices
       • Custom Taxonomies
       • Page Templates
       • Custom Fields
       • Custom Admin Columns
       • Custom Queries



             @codyhelgeson | @fallingupmedia | #wcphx
16




     Custom Admin Columns
     The Code

 http://codex.wordpress.org/Plugin_API/Action_Reference/
 manage_posts_custom_column

 http://codex.wordpress.org/Plugin_API/Filter_Reference/
 manage_edit-post_type_columns


 add_action("manage_posts_custom_column", "your_custom_post_column_function");

 add_filter("manage_edit-$post_type_columns", "your_custom_column_function");




               @codyhelgeson | @fallingupmedia | #wcphx
17



 http://blog.elliotcondon.com/wordpress/advanced-custom-fields-
 admin-custom-columns/


     function my_page_columns($columns)
     {
     " $columns = array(
     " " 'cb'" " => '<input type="checkbox" />',
     " " 'thumbnail'" =>"'Thumbnail',
     " " 'title' " => 'Title',
     " " 'featured' "=> 'Featured',
     " " 'author'" =>"'Author',
     " " 'date'" " =>"'Date',
     " );
     " return $columns;
     }




                 @codyhelgeson | @fallingupmedia | #wcphx
18


     function my_custom_columns($column)
     {
     " global $post;
     " if($column == 'thumbnail')
     " {
     " " echo wp_get_attachment_image( get_field('page_image', $post->ID), array(200,200) );
     " }
     " elseif($column == 'featured')
     " {
     " " if(get_field('featured'))
     " " {
     " " " echo 'Yes';
     " " }
     " " else
     " " {
     " " " echo 'No';
     " " }
     " }
     }
      
     add_action("manage_pages_custom_column", "my_custom_columns");
     add_filter("manage_edit-page_columns", "my_page_columns");



                    @codyhelgeson | @fallingupmedia | #wcphx
19




     Custom Admin Columns
     Examples




           @codyhelgeson | @fallingupmedia | #wcphx
20




 http://www.trymypoolguy.com

     function my_post_columns_forums($columns)
     {
     " $columns = array(
     " " 'cb'" " => '<input type="checkbox" />',
     " " 'title' " => 'Listing Title',
     " " 'featured'" => 'Featured',
     " " 'author'      => 'Author',
     " " 'comments' => '<img src="image_path_goes_here" />',
     " " 'zips'     => 'Zip Code',
     " " 'services'       => 'Services',
     " " 'repairs'      => 'Repairs',
     " " 'date'" " => 'Date',
     " );
     " return $columns;
     }




                @codyhelgeson | @fallingupmedia | #wcphx
21
     function my_custom_columns_forums($column)
     {
     "   global $post;
     "   if($column == 'featured')
     "   {
     "   "     if(get_field('featured'))
     "   "     {
     "   "     "    echo '<strong>Yes</strong>';
     "   "     }
     "   "     else
     "   "     {
     "   "     "    echo '';
     "   "     }
     "   }
     "   if($column == 'zips')
     "   {
     "   "     echo get_field('zip_code', $post->ID);
     "   }
     "   if($column == 'services')
     "   {
     "     $custom_fields = get_post_custom($post->ID);
     "     $my_custom_field = $custom_fields['services'];
     "     foreach ( $my_custom_field as $key => $value )
     "       echo $value . "<br />";
     "   }
     "   if($column == 'repairs')
     "   {
     "     $custom_fields = get_post_custom($post->ID);
     "     $my_custom_field = $custom_fields['repairs'];
     "     foreach ( $my_custom_field as $key => $value )
     "       echo $value . "<br />";
     "   }
22




     Custom Admin Columns
     Examples




           @codyhelgeson | @fallingupmedia | #wcphx
23




     Topics For The Day
     Custom Post Types

       • Custom Post Type Best Practices
       • Custom Taxonomies
       • Page Templates
       • Custom Fields
       • Custom Admin Columns
       • Custom Queries



             @codyhelgeson | @fallingupmedia | #wcphx
24




     Custom Queries
       http://codex.wordpress.org/Template_Tags/get_posts
      http://codex.wordpress.org/Class_Reference/WP_Query


      • get_posts
        • does not modify global variables
      • wp_query
        • always <?php wp_reset_query(); ?>




            @codyhelgeson | @fallingupmedia | #wcphx
25




     Custom Queries
     get posts from:
     custom post type - dogfood
     and category = brand
      <?php
      $args = array(
         'numberposts' => 8,
         'orderby' => 'rand',
         'post_type' => 'dogfood',
         'dogfood_category' => 'brand',
         'post_status' => 'publish'
      );
      $show_brands = get_posts ( $args );
      ?>




                  @codyhelgeson | @fallingupmedia | #wcphx
26




     Custom Queries
     Examples



        • Real world examples on the web......




            @codyhelgeson | @fallingupmedia | #wcphx
27




     Thank You!

      @codyhelgeson
      @fallingupmedia
      fallingupmedia.com
      cody@fallingupmedia.com




            @codyhelgeson | @fallingupmedia | #wcphx
28




           Custom Post Types
                  Now What?
                            By Cody Helgeson
                       WordCamp Phoenix 2012




     @codyhelgeson | @fallingupmedia | #wcphx

More Related Content

What's hot

Intro to Ruby on Rails
Intro to Ruby on RailsIntro to Ruby on Rails
Intro to Ruby on Railsrschmukler
 
Lose Your Head! Re-imagining WordPress's Role in Content Presentation
Lose Your Head! Re-imagining WordPress's Role in Content PresentationLose Your Head! Re-imagining WordPress's Role in Content Presentation
Lose Your Head! Re-imagining WordPress's Role in Content PresentationJeremy Ward
 
Django introduction @ UGent
Django introduction @ UGentDjango introduction @ UGent
Django introduction @ UGentkevinvw
 
Understanding the ins and outs of word press metadata
Understanding the ins and outs of word press metadataUnderstanding the ins and outs of word press metadata
Understanding the ins and outs of word press metadataNicholas Batik
 
The Transparent Web: Bridging the Chasm in Web Development
The Transparent Web: Bridging the Chasm in Web DevelopmentThe Transparent Web: Bridging the Chasm in Web Development
The Transparent Web: Bridging the Chasm in Web Developmenttwopoint718
 
Sass: The Future of Stylesheets
Sass: The Future of StylesheetsSass: The Future of Stylesheets
Sass: The Future of Stylesheetschriseppstein
 
Styling Components with JavaScript: MelbCSS Edition
Styling Components with JavaScript: MelbCSS EditionStyling Components with JavaScript: MelbCSS Edition
Styling Components with JavaScript: MelbCSS Editionbensmithett
 
Styling components with JavaScript
Styling components with JavaScriptStyling components with JavaScript
Styling components with JavaScriptbensmithett
 
WAI-ARIA is More Than Accessibility
WAI-ARIA is More Than AccessibilityWAI-ARIA is More Than Accessibility
WAI-ARIA is More Than Accessibility偉格 高
 
Javascript for the c# developer
Javascript for the c# developerJavascript for the c# developer
Javascript for the c# developerSalvatore Fazio
 

What's hot (12)

Intro to Ruby on Rails
Intro to Ruby on RailsIntro to Ruby on Rails
Intro to Ruby on Rails
 
Lose Your Head! Re-imagining WordPress's Role in Content Presentation
Lose Your Head! Re-imagining WordPress's Role in Content PresentationLose Your Head! Re-imagining WordPress's Role in Content Presentation
Lose Your Head! Re-imagining WordPress's Role in Content Presentation
 
Django introduction @ UGent
Django introduction @ UGentDjango introduction @ UGent
Django introduction @ UGent
 
Understanding the ins and outs of word press metadata
Understanding the ins and outs of word press metadataUnderstanding the ins and outs of word press metadata
Understanding the ins and outs of word press metadata
 
The Transparent Web: Bridging the Chasm in Web Development
The Transparent Web: Bridging the Chasm in Web DevelopmentThe Transparent Web: Bridging the Chasm in Web Development
The Transparent Web: Bridging the Chasm in Web Development
 
Sass: The Future of Stylesheets
Sass: The Future of StylesheetsSass: The Future of Stylesheets
Sass: The Future of Stylesheets
 
HTML5: Introduction
HTML5: IntroductionHTML5: Introduction
HTML5: Introduction
 
Jquery News Packages
Jquery News PackagesJquery News Packages
Jquery News Packages
 
Styling Components with JavaScript: MelbCSS Edition
Styling Components with JavaScript: MelbCSS EditionStyling Components with JavaScript: MelbCSS Edition
Styling Components with JavaScript: MelbCSS Edition
 
Styling components with JavaScript
Styling components with JavaScriptStyling components with JavaScript
Styling components with JavaScript
 
WAI-ARIA is More Than Accessibility
WAI-ARIA is More Than AccessibilityWAI-ARIA is More Than Accessibility
WAI-ARIA is More Than Accessibility
 
Javascript for the c# developer
Javascript for the c# developerJavascript for the c# developer
Javascript for the c# developer
 

Similar to Wordcamp Phoenix 2012 - Custom Post Types: Now What? By Cody Helgeson

WordPress 3 Custom Post Types
WordPress 3 Custom Post TypesWordPress 3 Custom Post Types
WordPress 3 Custom Post TypesDave Zille
 
Wordcamp St. Louis - Clean Coding
Wordcamp St. Louis - Clean CodingWordcamp St. Louis - Clean Coding
Wordcamp St. Louis - Clean Codinginspector_fegter
 
WordPress: A Designer's CMS
WordPress: A Designer's CMSWordPress: A Designer's CMS
WordPress: A Designer's CMSChelsea Otakan
 
The WordPress University 2012
The WordPress University 2012The WordPress University 2012
The WordPress University 2012Stephanie Leary
 
Wordpress beyond blogging
Wordpress beyond bloggingWordpress beyond blogging
Wordpress beyond bloggingJulien Minguely
 
Becoming a better WordPress Developer
Becoming a better WordPress DeveloperBecoming a better WordPress Developer
Becoming a better WordPress DeveloperJoey Kudish
 
Carrington Core (2014)
Carrington Core (2014)Carrington Core (2014)
Carrington Core (2014)alexkingorg
 
Simple Usability Tweaks for Your WordPress Theme
Simple Usability Tweaks for Your WordPress ThemeSimple Usability Tweaks for Your WordPress Theme
Simple Usability Tweaks for Your WordPress ThemeGraham Armfield
 
The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017Amanda Giles
 
Developing Complex WordPress Sites without Fear of Failure (with MVC)
Developing Complex WordPress Sites without Fear of Failure (with MVC)Developing Complex WordPress Sites without Fear of Failure (with MVC)
Developing Complex WordPress Sites without Fear of Failure (with MVC)Mike Schinkel
 
WordPress 3.4 Theme Customizer
WordPress 3.4 Theme CustomizerWordPress 3.4 Theme Customizer
WordPress 3.4 Theme CustomizerChandra Maharzan
 
What's New in WordPress 3.0 (for developers)
What's New in WordPress 3.0 (for developers)What's New in WordPress 3.0 (for developers)
What's New in WordPress 3.0 (for developers)Stephanie Leary
 
WP 101 - Custom Fields & Post Types
WP 101 - Custom Fields & Post TypesWP 101 - Custom Fields & Post Types
WP 101 - Custom Fields & Post TypesJoe Querin
 
Beyond Posts and Pages: Structured Content in WordPress
Beyond Posts and Pages: Structured Content in WordPressBeyond Posts and Pages: Structured Content in WordPress
Beyond Posts and Pages: Structured Content in WordPressJohn Eckman
 
The Way to Theme Enlightenment
The Way to Theme EnlightenmentThe Way to Theme Enlightenment
The Way to Theme EnlightenmentAmanda Giles
 
Tech Gupshup Meetup On MongoDB - 24/06/2016
Tech Gupshup Meetup On MongoDB - 24/06/2016Tech Gupshup Meetup On MongoDB - 24/06/2016
Tech Gupshup Meetup On MongoDB - 24/06/2016Mukesh Tilokani
 

Similar to Wordcamp Phoenix 2012 - Custom Post Types: Now What? By Cody Helgeson (20)

WordPress 3 Custom Post Types
WordPress 3 Custom Post TypesWordPress 3 Custom Post Types
WordPress 3 Custom Post Types
 
Wordcamp St. Louis - Clean Coding
Wordcamp St. Louis - Clean CodingWordcamp St. Louis - Clean Coding
Wordcamp St. Louis - Clean Coding
 
WordPress: A Designer's CMS
WordPress: A Designer's CMSWordPress: A Designer's CMS
WordPress: A Designer's CMS
 
The WordPress University 2012
The WordPress University 2012The WordPress University 2012
The WordPress University 2012
 
Theme Development from the Coding End
Theme Development from the Coding EndTheme Development from the Coding End
Theme Development from the Coding End
 
Dev Theming
Dev ThemingDev Theming
Dev Theming
 
Cain & Obenland — Episode 4
Cain & Obenland — Episode 4Cain & Obenland — Episode 4
Cain & Obenland — Episode 4
 
Wordpress beyond blogging
Wordpress beyond bloggingWordpress beyond blogging
Wordpress beyond blogging
 
Becoming a better WordPress Developer
Becoming a better WordPress DeveloperBecoming a better WordPress Developer
Becoming a better WordPress Developer
 
Carrington Core (2014)
Carrington Core (2014)Carrington Core (2014)
Carrington Core (2014)
 
Simple Usability Tweaks for Your WordPress Theme
Simple Usability Tweaks for Your WordPress ThemeSimple Usability Tweaks for Your WordPress Theme
Simple Usability Tweaks for Your WordPress Theme
 
The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017
 
Developing Complex WordPress Sites without Fear of Failure (with MVC)
Developing Complex WordPress Sites without Fear of Failure (with MVC)Developing Complex WordPress Sites without Fear of Failure (with MVC)
Developing Complex WordPress Sites without Fear of Failure (with MVC)
 
WordPress 3.4 Theme Customizer
WordPress 3.4 Theme CustomizerWordPress 3.4 Theme Customizer
WordPress 3.4 Theme Customizer
 
What's New in WordPress 3.0 (for developers)
What's New in WordPress 3.0 (for developers)What's New in WordPress 3.0 (for developers)
What's New in WordPress 3.0 (for developers)
 
Custom Fields & Custom Metaboxes Overview
Custom Fields & Custom Metaboxes OverviewCustom Fields & Custom Metaboxes Overview
Custom Fields & Custom Metaboxes Overview
 
WP 101 - Custom Fields & Post Types
WP 101 - Custom Fields & Post TypesWP 101 - Custom Fields & Post Types
WP 101 - Custom Fields & Post Types
 
Beyond Posts and Pages: Structured Content in WordPress
Beyond Posts and Pages: Structured Content in WordPressBeyond Posts and Pages: Structured Content in WordPress
Beyond Posts and Pages: Structured Content in WordPress
 
The Way to Theme Enlightenment
The Way to Theme EnlightenmentThe Way to Theme Enlightenment
The Way to Theme Enlightenment
 
Tech Gupshup Meetup On MongoDB - 24/06/2016
Tech Gupshup Meetup On MongoDB - 24/06/2016Tech Gupshup Meetup On MongoDB - 24/06/2016
Tech Gupshup Meetup On MongoDB - 24/06/2016
 

Recently uploaded

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 

Recently uploaded (20)

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 

Wordcamp Phoenix 2012 - Custom Post Types: Now What? By Cody Helgeson

  • 1. 1 Custom Post Types Now What? By Cody Helgeson WordCamp Phoenix 2012 @codyhelgeson | @fallingupmedia | #wcphx
  • 2. 2 Find More Info Who Am I? My Experience with WordPress @codyhelgeson @fallingupmedia fallingupmedia.com cody@fallingupmedia.com @codyhelgeson | @fallingupmedia | #wcphx
  • 3. 3 Topics For The Day • Custom Post Type Best Practices • Custom Taxonomies • Page Templates • Custom Fields • Custom Admin Columns • Custom Queries @codyhelgeson | @fallingupmedia | #wcphx
  • 4. 4 Custom Post Types • Who has or is about to use custom post types? • Why use custom post types • Why not? • For the client • For the developer @codyhelgeson | @fallingupmedia | #wcphx
  • 5. 5 Custom Post Types Examples • Book and Product Reviews • Job and Business Listings • Events and Locations • Portfolios and Case Studies • Combine with BuddyPress for Community Domination! • Anything your Heart Desires.... @codyhelgeson | @fallingupmedia | #wcphx
  • 6. 6 Custom Post Types The Code http://codex.wordpress.org/Function_Reference/register_post_type • Contextual help menus are a nice touch • Permalinks matter! • Flush the rewrite rules, or save permalink settings • /%category%/%postname%/ • www.domain.com/custom-post-type/post-title @codyhelgeson | @fallingupmedia | #wcphx
  • 7. 7 Topics For The Day • Custom Post Type Best Practices • Custom Taxonomies • Page Templates • Custom Fields • Custom Admin Columns • Custom Queries @codyhelgeson | @fallingupmedia | #wcphx
  • 8. 8 Custom Taxonomies http://codex.wordpress.org/Taxonomies • Categorizes and groups content • Hierarchal or not? I.E. tags or categories • Clean and intuitive for users • Custom slugs argument • Create custom page templates and queries @codyhelgeson | @fallingupmedia | #wcphx
  • 9. 9 Custom Taxonomies The Code http://codex.wordpress.org/Function_Reference/register_taxonomy • Flush rewrite or save permalink settings • There are reserved terms! • register_taxonomy($taxonomy, $object_type, $args);  @codyhelgeson | @fallingupmedia | #wcphx
  • 10. 10 Topics For The Day Custom Post Types • Custom Post Type Best Practices • Custom Taxonomies • Page Templates • Custom Fields • Custom Admin Columns • Custom Queries @codyhelgeson | @fallingupmedia | #wcphx
  • 11. 11 Page Templates http://codex.wordpress.org/Template_Hierarchy • WordPress makes it easy! Use them! • single-post_type.php • archive-post_type.php • taxonomy-taxonomy_name-slug.php • taxonomy-taxonomy_name.php @codyhelgeson | @fallingupmedia | #wcphx
  • 12. 12 Topics For The Day Custom Post Types • Custom Post Type Best Practices • Custom Taxonomies • Page Templates • Custom Fields • Custom Admin Columns • Custom Queries @codyhelgeson | @fallingupmedia | #wcphx
  • 13. 13 Custom Fields http://codex.wordpress.org/Custom_Fields • Purely incredible! Endless possibilities • Remove what you don’t need from editor. Take the time • Create your own or use a plugin • Advanced Custom Fields plugin • Magic Fields plugin • get_post_meta - add_post_meta @codyhelgeson | @fallingupmedia | #wcphx
  • 14. 14 Custom Fields Examples • Real world examples on the web...... @codyhelgeson | @fallingupmedia | #wcphx
  • 15. 15 Topics For The Day Custom Post Types • Custom Post Type Best Practices • Custom Taxonomies • Page Templates • Custom Fields • Custom Admin Columns • Custom Queries @codyhelgeson | @fallingupmedia | #wcphx
  • 16. 16 Custom Admin Columns The Code http://codex.wordpress.org/Plugin_API/Action_Reference/ manage_posts_custom_column http://codex.wordpress.org/Plugin_API/Filter_Reference/ manage_edit-post_type_columns add_action("manage_posts_custom_column", "your_custom_post_column_function"); add_filter("manage_edit-$post_type_columns", "your_custom_column_function"); @codyhelgeson | @fallingupmedia | #wcphx
  • 17. 17 http://blog.elliotcondon.com/wordpress/advanced-custom-fields- admin-custom-columns/ function my_page_columns($columns) { " $columns = array( " " 'cb'" " => '<input type="checkbox" />', " " 'thumbnail'" =>"'Thumbnail', " " 'title' " => 'Title', " " 'featured' "=> 'Featured', " " 'author'" =>"'Author', " " 'date'" " =>"'Date', " ); " return $columns; } @codyhelgeson | @fallingupmedia | #wcphx
  • 18. 18 function my_custom_columns($column) { " global $post; " if($column == 'thumbnail') " { " " echo wp_get_attachment_image( get_field('page_image', $post->ID), array(200,200) ); " } " elseif($column == 'featured') " { " " if(get_field('featured')) " " { " " " echo 'Yes'; " " } " " else " " { " " " echo 'No'; " " } " } }   add_action("manage_pages_custom_column", "my_custom_columns"); add_filter("manage_edit-page_columns", "my_page_columns"); @codyhelgeson | @fallingupmedia | #wcphx
  • 19. 19 Custom Admin Columns Examples @codyhelgeson | @fallingupmedia | #wcphx
  • 20. 20 http://www.trymypoolguy.com function my_post_columns_forums($columns) { " $columns = array( " " 'cb'" " => '<input type="checkbox" />', " " 'title' " => 'Listing Title', " " 'featured'" => 'Featured', " " 'author' => 'Author', " " 'comments' => '<img src="image_path_goes_here" />', " " 'zips' => 'Zip Code', " " 'services' => 'Services', " " 'repairs' => 'Repairs', " " 'date'" " => 'Date', " ); " return $columns; } @codyhelgeson | @fallingupmedia | #wcphx
  • 21. 21 function my_custom_columns_forums($column) { " global $post; " if($column == 'featured') " { " " if(get_field('featured')) " " { " " " echo '<strong>Yes</strong>'; " " } " " else " " { " " " echo ''; " " } " } " if($column == 'zips') " { " " echo get_field('zip_code', $post->ID); " } " if($column == 'services') " { " $custom_fields = get_post_custom($post->ID); " $my_custom_field = $custom_fields['services']; " foreach ( $my_custom_field as $key => $value ) " echo $value . "<br />"; " } " if($column == 'repairs') " { " $custom_fields = get_post_custom($post->ID); " $my_custom_field = $custom_fields['repairs']; " foreach ( $my_custom_field as $key => $value ) " echo $value . "<br />"; " }
  • 22. 22 Custom Admin Columns Examples @codyhelgeson | @fallingupmedia | #wcphx
  • 23. 23 Topics For The Day Custom Post Types • Custom Post Type Best Practices • Custom Taxonomies • Page Templates • Custom Fields • Custom Admin Columns • Custom Queries @codyhelgeson | @fallingupmedia | #wcphx
  • 24. 24 Custom Queries http://codex.wordpress.org/Template_Tags/get_posts http://codex.wordpress.org/Class_Reference/WP_Query • get_posts • does not modify global variables • wp_query • always <?php wp_reset_query(); ?> @codyhelgeson | @fallingupmedia | #wcphx
  • 25. 25 Custom Queries get posts from: custom post type - dogfood and category = brand <?php $args = array( 'numberposts' => 8, 'orderby' => 'rand', 'post_type' => 'dogfood', 'dogfood_category' => 'brand', 'post_status' => 'publish' ); $show_brands = get_posts ( $args ); ?> @codyhelgeson | @fallingupmedia | #wcphx
  • 26. 26 Custom Queries Examples • Real world examples on the web...... @codyhelgeson | @fallingupmedia | #wcphx
  • 27. 27 Thank You! @codyhelgeson @fallingupmedia fallingupmedia.com cody@fallingupmedia.com @codyhelgeson | @fallingupmedia | #wcphx
  • 28. 28 Custom Post Types Now What? By Cody Helgeson WordCamp Phoenix 2012 @codyhelgeson | @fallingupmedia | #wcphx

Editor's Notes

  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
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n