SlideShare a Scribd company logo
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 Rails
rschmukler
 
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
Jeremy Ward
 
Django introduction @ UGent
Django introduction @ UGentDjango introduction @ UGent
Django introduction @ UGent
kevinvw
 
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
Nicholas 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 Development
twopoint718
 
Sass: The Future of Stylesheets
Sass: The Future of StylesheetsSass: The Future of Stylesheets
Sass: The Future of Stylesheets
chriseppstein
 
HTML5: Introduction
HTML5: IntroductionHTML5: Introduction
HTML5: Introduction
Guillermo Paz
 
Jquery News Packages
Jquery News PackagesJquery 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
bensmithett
 
Styling components with JavaScript
Styling components with JavaScriptStyling components with JavaScript
Styling components with JavaScript
bensmithett
 
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
Salvatore 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 Types
Dave Zille
 
Wordcamp St. Louis - Clean Coding
Wordcamp St. Louis - Clean CodingWordcamp St. Louis - Clean Coding
Wordcamp St. Louis - Clean Coding
inspector_fegter
 
WordPress: A Designer's CMS
WordPress: A Designer's CMSWordPress: A Designer's CMS
WordPress: A Designer's CMS
Chelsea Otakan
 
The WordPress University 2012
The WordPress University 2012The WordPress University 2012
The WordPress University 2012
Stephanie Leary
 
Dev Theming
Dev ThemingDev Theming
Dev Theming
beedragon
 
Theme Development from the Coding End
Theme Development from the Coding EndTheme Development from the Coding End
Theme Development from the Coding End
East Bay WordPress Meetup
 
Cain & Obenland — Episode 4
Cain & Obenland — Episode 4Cain & Obenland — Episode 4
Cain & Obenland — Episode 4
Konstantin Obenland
 
Wordpress beyond blogging
Wordpress beyond bloggingWordpress beyond blogging
Wordpress beyond blogging
Julien Minguely
 
Becoming a better WordPress Developer
Becoming a better WordPress DeveloperBecoming a better WordPress Developer
Becoming a better WordPress Developer
Joey 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 Theme
Graham Armfield
 
The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017
Amanda 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 Customizer
Chandra 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
 
Custom Fields & Custom Metaboxes Overview
Custom Fields & Custom Metaboxes OverviewCustom Fields & Custom Metaboxes Overview
Custom Fields & Custom Metaboxes Overview
East Bay WordPress Meetup
 
WP 101 - Custom Fields & Post Types
WP 101 - Custom Fields & Post TypesWP 101 - Custom Fields & Post Types
WP 101 - Custom Fields & Post Types
Joe 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 WordPress
John Eckman
 
The Way to Theme Enlightenment
The Way to Theme EnlightenmentThe Way to Theme Enlightenment
The Way to Theme Enlightenment
Amanda 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/2016
Mukesh 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
 
Dev Theming
Dev ThemingDev Theming
Dev Theming
 
Theme Development from the Coding End
Theme Development from the Coding EndTheme Development from the Coding End
Theme Development from the Coding End
 
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

What is an RPA CoE? Session 2 – CoE Roles
What is an RPA CoE?  Session 2 – CoE RolesWhat is an RPA CoE?  Session 2 – CoE Roles
What is an RPA CoE? Session 2 – CoE Roles
DianaGray10
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
Safe Software
 
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
DanBrown980551
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
Antonios Katsarakis
 
From Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMsFrom Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMs
Sease
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
c5vrf27qcz
 
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid ResearchHarnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Neo4j
 
Must Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during MigrationMust Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during Migration
Mydbops
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
Jason Yip
 
"NATO Hackathon Winner: AI-Powered Drug Search", Taras Kloba
"NATO Hackathon Winner: AI-Powered Drug Search",  Taras Kloba"NATO Hackathon Winner: AI-Powered Drug Search",  Taras Kloba
"NATO Hackathon Winner: AI-Powered Drug Search", Taras Kloba
Fwdays
 
Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
BibashShahi
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
Alex Pruden
 
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
Fwdays
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
UiPathCommunity
 
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansBiomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Neo4j
 
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Pitangent Analytics & Technology Solutions Pvt. Ltd
 
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptxPRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
christinelarrosa
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
A Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's ArchitectureA Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's Architecture
ScyllaDB
 

Recently uploaded (20)

What is an RPA CoE? Session 2 – CoE Roles
What is an RPA CoE?  Session 2 – CoE RolesWhat is an RPA CoE?  Session 2 – CoE Roles
What is an RPA CoE? Session 2 – CoE Roles
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
 
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
 
From Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMsFrom Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMs
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
 
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid ResearchHarnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
 
Must Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during MigrationMust Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during Migration
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
 
"NATO Hackathon Winner: AI-Powered Drug Search", Taras Kloba
"NATO Hackathon Winner: AI-Powered Drug Search",  Taras Kloba"NATO Hackathon Winner: AI-Powered Drug Search",  Taras Kloba
"NATO Hackathon Winner: AI-Powered Drug Search", Taras Kloba
 
Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
 
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
 
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansBiomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
 
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
 
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptxPRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
A Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's ArchitectureA Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's Architecture
 

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