Automating Google Workspace (GWS) & more with Apps Script
Using Custom Fields For Fun And Profit
1. Using Custom Fields
For Fun and Profit
WordCamp Fraser Valley 2009
Dave Zille
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. 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. 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. 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. 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. 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. 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)