CALL ON ➥8923113531 🔝Call Girls Adil Nagar Lucknow best Female service
WordPress Custom Fields and Metaboxes
1. Technology Hotspot & Salon
WordPress Custom
Fields and Metaboxes
East Bay WordPress Meetup
268 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
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. 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
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
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. 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. Event Post Type
•Custom Post Type + Metaboxes
•Implemented in a plugin
Custom Metabox
Custom Metabox Posts 2 Posts FTW
13 www.techliminal.com
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
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. Create an array for the
What 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. 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