Custom Post Types in WordPress

1,697 views

Published on

My presentation for WordCamp New Zealand

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,697
On SlideShare
0
From Embeds
0
Number of Embeds
194
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide



  • Talking about namespacing and writing good code









  • even more technical





  • Custom Post Types in WordPress

    1. 1. Custom Post Types Anthony Cole, WordCamp New Zealand
    2. 2. Welcome @anthonycole on twitter WordCamp Australia February 2011 - Come Along
    3. 3. Today A note on coding standards Defining “Post Types” or “Content Types” Give an example of Custom Post Types Open up to questions about Custom Post Types
    4. 4. Coding Standards Coding standards are very very important If you’re releasing a public plugin, things can go wrong if you don’t use namespaces The biggest problem with the plugin repository is a lack of following coding standards Version control. Version control is important (<3 git)
    5. 5. Namespacing Prepend function names with something - anything! For example, an events plugin - could use evnt_show_events instead of just show_events This is good - you avoid conflicts! show_events is bad
    6. 6. Write good code Brace Style Single-line conditionals http://codex.wordpress.org/ WordPress_Coding_Standards
    7. 7. Bad
    8. 8. Good
    9. 9. Content Types WordPress can handle any type of content Content Types allow you to manage your data Optimised for limitless amounts of data - example, WP.com Defaults: Revisions, Posts, Pages
    10. 10. “Custom” Post Types Wrapped around your content - it makes managing things easier Moulded to your data - Events, books, cars, anything Increase Productivity
    11. 11. Example - Registration
    12. 12. Example - Calling a Post Type
    13. 13. Custom Post Types UI
    14. 14. Getting technical Use register_post_type in an init hook Remember, namespacing Attributes - labels, supports metaboxes You can use single-type.php (single-event.php) URL routes (so /event/)
    15. 15. Even More Technical Utilise taxonomies - you can tack on categories or any other taxonomy to a post type Post Types Manager Threading
    16. 16. Examples Basic- UNSW Hothouse - Basic events Technical - WordPress.com css revisions Uses revisions Theme: Estate by WooThemes
    17. 17. UNSW Hothouse
    18. 18. More Info http:// codex.wordpress.org/ Custom_Post_Types http:// codex.wordpress.org/ Function_Reference/ register_post_type
    19. 19. Question Time Ask me anything!

    ×