Using Custom Fields For Fun And Profit

1,272 views

Published on

Using WordPress custom fields for fun and profit, a presentation at WordCamp Fraser Valley, 2009.

Published in: 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,272
On SlideShare
0
From Embeds
0
Number of Embeds
26
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Using Custom Fields For Fun And Profit

  1. 1. Using Custom Fields For Fun and Profit WordCamp Fraser Valley 2009 Dave Zille
  2. 2. Contact Info Dave Zille Email: dave@dazil.com Twitter: @dazil Skype: davezille Web: http://www.dazil.com Blog: http://www.dazil.com/blog
  3. 3. Outline WordPress custom fields What is a Custom Field? How do I use them? Usage examples Fun Add interesting info to your blog posts or pages Add images/thumbnails to posts or pages Profit Add Shopping Cart to your WordPress site
  4. 4. WordPress Custom Fields What is a custom field? A little bit of information you can store alongside a WordPress post or page A custom field has two components A key/value "pair" Key is the name of the meta data element eg. image Value is the information itself eg. "myphoto.jpg" Examples: Key: url Value: "http://www.mysite.net" Key: my_mood Value: "Happy as a clam"
  5. 5. WordPress Custom Fields Usage: WordPress function get_post_meta() get_post_meta($post_id, $key, $single) Example: get_post_meta($post->id, "my_mood", true) will return: "Happy as a Clam" Demo
  6. 6. Custom Field Usage Examples Demo site: Comic Sightings Adding contributor information to a post: Custom field key: credit-name Demo see single.php (sample code)
  7. 7. Custom Field Usage Examples Demo site: Comic Sightings Adding photos to a post: Custom field key: main-image Demo see product-demo.php (sample code)
  8. 8. Custom Field Usage Examples Demo site: Comic Sightings Adding a shopping cart Custom field keys: price, product-name Demo see product-demo.php (sample code)
  9. 9. Questions? Slides and sample code: Web: http://www.dazil.com/blog

×