WordPress Data Storage

1,233 views

Published on

Slides from my presentation at SWIG Liverpool covering the various options for data storage and handling within WordPress

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

  • Be the first to like this

No Downloads
Views
Total views
1,233
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

WordPress Data Storage

  1. 1. Data Damian GostomskiHandling in @damiangostomski http://gostomski.co.ukWordPress
  2. 2. Intro Lots of options for data handling Why I will not teach you everything Overview about them, I will raise your CPTs awareness of themTaxonomies Users Options Database Files External Summary Questions
  3. 3. Intro Why do we need additional data Why handling? Overview CPTsTaxonomies Users Options Database Files External Summary Questions
  4. 4. Intro WordPress is now a full blown Why CMS, used for all sorts of sites. Overview CPTsTaxonomies Users Options Database Files External Summary Questions
  5. 5. Intro Custom Custom Why Post Type Taxonomies Overview CPTsTaxonomies Users Options Users Options Database Database Files Files External Summary External Questions
  6. 6. Intro Make your own post types. Why WordPress handles most of the Overview logic. CPTsTaxonomies Examples: Users • Events Options • Portfolio items Database Files • Products External • Services Summary Questions • Questions
  7. 7. Intro Store additional content in post Why meta. Overview CPTsTaxonomies Users Options Database Files External Summary Questions
  8. 8. Intro Use the standard template loop Why and template tags to render. Overview archive-$posttype.php / single- CPTs $posttype.phpTaxonomies Users Options Database Files External Summary Questions
  9. 9. Intro register_post_type($type, $args) Why • Label Overview • Public CPTs • Show UITaxonomies Users • Capability Type Options • Hierarchical Database • Supports Files • Register metabox External • Has Archive Summary • Rewrite Questions
  10. 10. Intro Establish relationship between Why CPTs. Overview Make your own, or use existing CPTs taxonomies.Taxonomies Examples: Users Options • Film Genre Database • Event type Files External • Product categories Summary • Group users by type Questions
  11. 11. Intro Users are data structures too. Why Useful for social/community, Overview directory and multi author sites. CPTsTaxonomies Can store anything in user meta. Users Can apply taxonomies to users Options too! Database Files External Summary Questions
  12. 12. Intro Site wide named pieces of data. Why Can store any data structure, Overview String, Integer, Array or Object. CPTsTaxonomies Multiple options vs single Users structure? Options Database Files External Summary Questions
  13. 13. Intro add_option($key, $data, ‘’, ‘yes’) Why update_option($key, $data) Overview CPTs get_option($key, $default)Taxonomies delete_option($key) Users Options Database Files External Summary Questions
  14. 14. Intro The Transient API offers a simple Why way to cache data: Overview set_transient($key, $data, $expire) CPTsTaxonomies get_transient($key) Users delete_transient($key) Options Database Files External Summary Questions
  15. 15. Intro Direct access via $wpdb Why Create database tables on plugin Overview activation. CPTsTaxonomies Escape all input! Users Options Database Files External Summary Questions
  16. 16. Intro Can write files to the uploads Why folder - can’t guarantee elsewhere! Overview WordPress offers a File System API CPTs to get around that.Taxonomies Users Options Database Files External Summary Questions
  17. 17. Intro Lots of websites share their Why content using APIs. Overview More often pull than push. CPTsTaxonomies Example APIs: Users • Social media Options Database • Payment services Files • Maps External • Web services Summary • Web apps Questions
  18. 18. Intro WordPress offers us a HTTP API Why to make our lives easier. Use it! Overview wp_remote_get($url, $args) CPTsTaxonomies wp_remote_post($url, $args) Users Options Database Files External Summary Questions
  19. 19. Intro No one right method, it depends Why on: Overview • Number of items CPTsTaxonomies • Complexity Users • Relations Options Database • Existing data availability Files • Customisation External Summary • Site wide settings Questions
  20. 20. Intro WordPress has an API for most Why tasks, use them! Overview Custom Post Types can fulfil your CPTs requirements in 90% of cases.Taxonomies Users No reason you can’t use a hybrid Options of these methods. Database Files External Summary Questions
  21. 21. Intro … Or can we go to the pub? Why Overview CPTsTaxonomies Damian Gostomski Users Options @damiangostomski Database http://gostomski.co.uk Files External Summary Questions

×