WordPress Custom Fields and Metaboxes

1,148 views

Published on

Learn why and how to create custom fields and metaboxes for you

Published in: Self Improvement
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,148
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
9
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

WordPress Custom Fields and Metaboxes

  1. 1. Technology Hotspot & Salon WordPress Custom Fields and Metaboxes East Bay WordPress Meetup268 14th Street, Oakland, CA 94612 | Open 11-7 Monday - Friday | Drop-in co-working space, workshops and technology services | More info: http://www.techliminal.com 1 Content in this presentation is Copyright (c) 2010 Tech Liminal. CC-Share-Alike. Feel free to use stuff from this presentation, but leave a link to Tech Liminal
  2. 2. Introduction Anca Tech Liminal • Web Developer • Technology Hotspot & Salon • Information Architect • Co-Working • 15 years of experience in • Workshops, Conferences technology & marketing orgs • Expert, friendly help with web & • Freelancer, Entrepreneur social media anca@techliminal.com www.techliminal.com 2 Content © 2011, Tech Liminal
  3. 3. Agenda • Why Custom Fields / Metaboxes • Example 1: Directory Website • Example 2: Conference Website • WP Alchemy • Custom Fields in the Database 3 www.techliminal.com
  4. 4. Why? • Custom post types + custom fields turn WordPress from a blogging/CMS into a viable tool for operating your business • Domain knowledge (e.g. events, products, etc) • Make it easier for users to put information in the right place 4 www.techliminal.com
  5. 5. Directory Website 5
  6. 6. Montclair Village Directory Website Listing by category Custom Information for each business 6 www.techliminal.com
  7. 7. Montclair Village Directory Website Custom Fields in the Custom Metabox Database 7 www.techliminal.com
  8. 8. Compare With Plain Custom Fields “Plain” Custom Fields Custom Metabox •Easier to remember what needs to be filled in •Better user experience for new people 8 www.techliminal.com
  9. 9. How This is Displayed 9 www.techliminal.com
  10. 10. Conference Website 10
  11. 11. Scenario • International conference with events held during 1 week in September/February • Local Event Organizers create and manage their own events • About 300 Organizers, 1000 events each time around • These are not WordPress experts • They only use this tool for 8 weeks/year 11 www.techliminal.com
  12. 12. Some Design Concerns • Each Metabox matches to a particular part of the event organization process • Some information is not accessible to all users • Designed based on how the application is going to be used. • Minimize support requests, questions, errors. 12 www.techliminal.com
  13. 13. Event Post Type •Custom Post Type + Metaboxes •Implemented in a plugin Custom Metabox Custom Metabox Posts 2 Posts FTW 13 www.techliminal.com
  14. 14. On The Front End 14 www.techliminal.com
  15. 15. MetaBoxes: WP Alchemy • http://www.farinspace.com/wpalchemy-metabox/ • Add to a folder in your theme or plugin • Build HTML metaboxes • Makes Saving and Retrieving Easier Subfolder in my Plugin 15 www.techliminal.com
  16. 16. MetaBoxes: WP Alchemy mb_event_info.php - Metabox template you control. 16 www.techliminal.com
  17. 17. MetaBoxes: Putting It In the Post show it only on my “event” post type (in plugin code) Individual, rather than array of, fields Not sure why, but it has to be loaded on init, rather than admin_init 17 www.techliminal.com
  18. 18. Create an array for theWhat About Searches? custom field values to query. Add each field value to the meta_query array, with compare property This checks for a single vlaue Add the Meta_query to the query args Perform the query 18 www.techliminal.com
  19. 19. Resources • WordPress for Programmers: TL Class Starting in January • Tech Liminal WordPress Support Group • http://techliminal.com/wordpress-support-group • WP Alchemy: http://www.farinspace.com/wpalchemy-metabox/ • Tammy Hart’s reusable Metaboxes: • https://github.com/tammyhart/Reusable-Custom-WordPress-Meta-Boxes • http://codex.wordpress.org/Function_Reference/add_meta_box • Learn about adding metaboxes • http://codex.wordpress.org/Function_Reference/register_post_type • Create your custom post type • http://codex.wordpress.org/Function_Reference/get_post_meta - How to get (and set) custom fields programmatically 19 www.techliminal.com

×