SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

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
 
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
 
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
 
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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
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
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
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
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
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
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 

Kürzlich hochgeladen (20)

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
 
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
 
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
 
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)
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
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...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
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...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 

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

Hinweis der Redaktion

  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