Your SlideShare is downloading. ×
0
Custom Post Types and Taxonomies
Custom Post Types and Taxonomies
Custom Post Types and Taxonomies
Custom Post Types and Taxonomies
Custom Post Types and Taxonomies
Custom Post Types and Taxonomies
Custom Post Types and Taxonomies
Custom Post Types and Taxonomies
Custom Post Types and Taxonomies
Custom Post Types and Taxonomies
Custom Post Types and Taxonomies
Custom Post Types and Taxonomies
Custom Post Types and Taxonomies
Custom Post Types and Taxonomies
Custom Post Types and Taxonomies
Custom Post Types and Taxonomies
Custom Post Types and Taxonomies
Custom Post Types and Taxonomies
Custom Post Types and Taxonomies
Custom Post Types and Taxonomies
Custom Post Types and Taxonomies
Custom Post Types and Taxonomies
Custom Post Types and Taxonomies
Custom Post Types and Taxonomies
Custom Post Types and Taxonomies
Custom Post Types and Taxonomies
Custom Post Types and Taxonomies
Custom Post Types and Taxonomies
Custom Post Types and Taxonomies
Custom Post Types and Taxonomies
Custom Post Types and Taxonomies
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Custom Post Types and Taxonomies

6,301

Published on

WordPress just got CMSier

WordPress just got CMSier

Published in: Technology
1 Comment
7 Likes
Statistics
Notes
No Downloads
Views
Total Views
6,301
On Slideshare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
65
Comments
1
Likes
7
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Custom Post Types &amp; Taxonomies<br />WordPress just got CMSier<br />
  • 2. Who Am I?<br />I am a self-taught, freelance designer who has leveraged trial, error, and observation to become a WordPress expert. <br />While I specialize in WordPress themes and CMS development, I also do all levels of Web Design and XHTML/CSS coding.<br />I freelance some through my personal brand, Tammy Hart Designs, and I also work a full time gig at Infomediahere in Birmingham.<br />TammyHartDesigns.com tammy@tammyhartdesigns.com @tammyhart<br />
  • 3. What is a Post Type?<br />Posts, pages and more! Oh my!<br />
  • 4. How Does it Work?<br />Content goes into the posts table<br />Each content item is assigned a post_type<br />Custom types are now easier to create and manage<br />
  • 5. Built in Types<br />Main Content<br />Post<br />Page<br />Other<br />Attachment<br />Revision<br />Nav Menu Item<br />
  • 6. What Is a taxonomy?<br />Read my lips, now new taxonomies<br />
  • 7. How Do They Work?<br />Terms and their unique ID’s are saved in the terms table<br />Terms are assigned a taxonomy in the term_taxonomy table<br />Terms are related to posts (of all types) in the term_relationships table<br />
  • 8. Built in Taxonomies<br />Post Taxonomies<br />Category<br />Post Tag<br />Other<br />Link Category<br />Nav Menu<br />
  • 9. Hand Coding<br />The hard way<br />
  • 10. Register a Post Type<br />function post_type_movies(){<br /> register_post_type(&apos;movies&apos;,<br /> array(&apos;label&apos;=&gt; __(&apos;Movies&apos;), <br /> &apos;public&apos;=&gt;true, <br /> &apos;show_ui&apos;=&gt;true,<br />&apos;supports&apos; =&gt;array(<br />&apos;post-thumbnails&apos;,<br />&apos;excerpts&apos;,<br /> &apos;trackbacks&apos;,<br /> &apos;custom-fields&apos;,<br /> &apos;comments&apos;,<br /> &apos;revisions&apos;)<br />)<br />);<br /> register_taxonomy_for_object_type(&apos;post_tag&apos;, &apos;movies&apos;);<br />}<br />add_action(&apos;init&apos;, &apos;post_type_movies&apos;);<br />First Impressions of Custom Post Type by Frank Bültge on WPEngineer.org<br />http://bit.ly/posttypes<br />
  • 11. Default Arguments<br />// Args prefixed with an underscore are reserved for internal use.<br />$defaults =array(<br />&apos;label&apos; =&gt;false,<br />&apos;publicly_queryable&apos; =&gt; null,<br />&apos;exclude_from_search&apos; =&gt; null,<br />&apos;_builtin&apos; =&gt;false,<br />&apos;_edit_link&apos; =&gt;&apos;post.php?post=%d&apos;,<br />&apos;capability_type&apos;=&gt;&apos;post&apos;,<br />&apos;hierarchical&apos; =&gt; false,<br />&apos;public&apos; =&gt; false,<br />&apos;rewrite&apos; =&gt;true,<br />&apos;query_var&apos; =&gt;true,<br />&apos;supports&apos; =&gt;array(),<br />&apos;register_meta_box_cb&apos; =&gt; null,<br />&apos;taxonomies&apos; =&gt;array(),<br />&apos;show_ui&apos; =&gt; null<br />);<br />First Impressions of Custom Post Type by Frank Bültge on WPEngineer.org<br />http://bit.ly/posttypes<br />
  • 12. The Taxonomy Code<br />function post_type_movies(){<br />…<br />register_taxonomy(&apos;actor&apos;, &apos;movies&apos;, <br />array(<br />&apos;hierarchical&apos;=&gt;true, <br />&apos;label&apos;=&gt; __(&apos;Actor&apos;)<br />) <br />); <br />register_taxonomy(‘director&apos;, &apos;movies&apos;,<br />array(<br /> &apos;hierarchical&apos;=&gt;false,<br />&apos;label&apos;=&gt;__(‘Director&apos;),<br />&apos;query_var&apos;=&gt;‘director&apos;,<br />&apos;rewrite&apos; =&gt;array(&apos;slug&apos;=&gt;‘director&apos;)<br /> )<br /> );<br />}<br />add_action(&apos;init&apos;, &apos;post_type_movies&apos;);<br />First Impressions of Custom Post Type by Frank Bültge on WPEngineer.org<br />http://bit.ly/posttypes<br />
  • 13. Using Plugins<br />The easy way<br />
  • 14. “<br />Overheard<br />WordCamp Birmingham 2009<br />WordPress is the iPhone of the internet. You’ll always hear, “There’s a plugin for that!”<br />
  • 15. Plugins for Creating Them<br />Custom Post Type UI<br />Creates both<br />TONS of labeling options<br />WP Post Type UI<br />Creates both<br />Buggy<br />Allows a custom icon<br />More Types &amp; More Taxonomies<br />Allows you to override built in types and taxonomies<br />Allows a custom icon<br />Works seamlessly with the More Fields plugin (stay tuned for more)<br />
  • 16. Plugins for Manipulating Them<br />Custom Post Type Order<br />Drag and drop ordering<br />Simple Custom Post Type Archives<br />Adds support for custom post type archive permalinks<br />Adds new body classes to custom post type archives<br />Adds a new conditional, is_custom_post_type_archive<br />Fixes the wp_title output on custom post type archives to show the custom type&apos;s label<br />Adds custom post type feeds<br />And more…<br />Post Type Switcher<br />Change the post type one item at a time<br />Convert Post Types<br />Bulk edit post types<br />
  • 17. Custom Templates<br />Now what do I do?<br />
  • 18. Template Hierarchy<br />Custom Post Type<br />single-{post_type}.php<br />single.php<br />index.php<br />Custom Taxonomy<br />taxonomy-{taxonomy}-{term}.php<br />taxonomy-{taxonomy}.php<br />taxonomy.php<br />archive.php<br />index.php<br />
  • 19. Custom Loops &amp; Queries<br />This gets hardcore<br />
  • 20. The Loop<br />The Basic Loop<br />&lt;?<br />$loop =newWP_query(&apos;post_type=movies&apos;);<br />while ($loop-&gt;have_posts()): $loop-&gt;the_post();<br />?&gt;<br />... Do Stuff Here ...<br />&lt;?endwhile; ?&gt;<br />Add Custom Taxonomies<br />$loop =newWP_query(&apos;post_type=movies&amp;actor=joaquin-phoenix&apos;);<br />$loop =newWP_query(&apos;post_type=movies&amp;actor=joaquin-phoenix&amp;director=m-night-shyamalan&apos;);<br />
  • 21. Term Lists<br />Get All Terms<br />$terms =get_terms(&apos;actors&apos;, &apos;order_by=count&amp;order=DESC&apos;);<br />Get Terms in a Post<br />get_the_term_list( $post-&gt;ID, &apos;actors&apos;, &apos;&lt;p&gt;Actors: &apos;, &apos;,&apos;, &apos;&lt;/p&gt;&apos; )<br />Other Functions<br />get_term<br />get_term_children<br />get_term_by<br />get_taxonomies<br />
  • 22. More Custom Content<br />But wait, there’s more!<br />
  • 23. “<br />Matt Mullenweg<br />WordCamp Birmingham 2009<br />I like what you’re doing; I just don’t like the way you’re having to do it. So I’m going to make it better.<br />
  • 24. No More Flutter<br />Custom Post Typesto create the special content<br />Custom Taxonomiesto organize the content<br />Custom Fieldsto get specific information on each post in a way that is human and pretty<br />
  • 25. Thanks!<br />Questions?<br />TammyHartDesigns.comtammy@tammyhartdesigns.com@tammyhart<br />

×