Slides from my WordCamp Buffalo 2014 talk on Structuring Content in WordPress using the Advanced Custom Fields plugin. This page will be updated with accompanying wordpress.tv link as soon as it becomes available!
2. Hello!
I’m Jamie Schmid.
EX-DESIGNER, CURRENT WORDPRESS ENTHUSIAST & INFORMATION ARCHITECT
FREELANCE, CORPORATE & IN-BETWEEN
PORTLAND, OR
@jamieschmid
3. Why Custom Fields?
Structuring content is more important than ever
Take site out of WYSIWYG box
Chunks vs blobs: break content into manageable blocks
Serve together on one page, or divide & send to mobile, API,
anywhere else
COPE: Create once, publish everywhere
Good experience for content publishers
4. Custom Post Types vs Taxonomies
vs Custom Fields
Custom Post Types: WP has 2 different “post” types: post & page.
Taxonomy: Means of classifying things. Puts the post into a group.
Category and Tags are examples of taxonomies.
Custom Fields: Data items consisting of a key/value pair, that must be
bound to a content type. Store custom information about the object
they are attached to. Default page already has fields: title field,
WYSIWYG field, featured image field. These are the same thing,
except custom to your own content. You’re just making up field
name, value, and adding the tag to the template field ( the_title();
the_content(); ) yourself!
5. Why Advanced Custom Fields?
o Difficulty in entering content interrupts the
editor’s workflow
o Core custom fields interface is confusing,
not user friendly - lots of work to customize
and limit
o ACF provides an extremely easy to use GUI,
fantastic documentation and support
http://www.advancedcustomfields.com/
6. ACF - Available Fields
Basic Fields
Text / Text Area
Number
Email
Password
Date/Color picker
Content
WYSIWYG full or ltd
Image
File
Choice
Select
Radio Button
Checkbox
True/False
Relational
Page Link
Post Object
Relationship
Taxonomy
User
jQuery
Google Map
Date Picker
Color Picker
Layout
Message
Tab
Flex Content *
Repeater *
Gallery *
Options *
* Pro only: $25 single site, $100 lifetime unlmited
14. OPTIONS FIELD use case: content that is repeated in various places across the site
15.
16. REPEATER FIELD use case: content whose format is repeated numerous times on a page
17.
18. REPEATER FIELD use case: easy for user to add their own accordions on a page
19.
20.
21.
22. Conditional Statements
In Your Theme:
Best practice to display CF’s with a
conditional
Can display certain support
elements only if field exists
Add class to body
Display alternate data
Only display posts with a specific
custom field
In the Admin:
Setting expiration date for posts
Page-specific content types
Extended publish statuses
26. Content Modeling
Planning your content types before you build
is important.
Wireframe every page
You will probably find there are
more pages than you thought.
Maybe even whole sections,
navigations and layouts.
Use standard naming conventions &
language the user will understand
Identify unique blocks
That require special tags, special
format, or shared content: these
are probably good custom field
candidates!
But be realistic.
Draw a balance between strictly
structured content, and freedom for
the author to enter all the content
they need
We don’t want to make the author
bend their content to fit your
structure
Get content as early as you can!
Build out all your Custom Post Types,
Custom Fields and Taxonomies at
the onset; develop the template
while your client populates their
content on staging!
27. Admin UX
Custom Fields Can GREATLY improve the Admin Panel User Experience!
Hide unused page elements
Field & Metabox naming conventions
Logical grouping of related fields
Tabs
Page placement – top, main, sidebar
Conditionals for showing different inputs
Input Validation
Notes/directions
28. Potential Issues
ACF Plugin must be installed for metadata fields to show
Can export as PHP for mu_plugins
wp_search: only searches the_content() – no custom fields
Search WP & Faceted Search plugins
rss: only feeds the_content()
Localization plugins: only translates the_content() (typically)
ACF text output is not escaped like native WordPress functions
https://github.com/10up/secured-advanced-custom-fields
http://codex.wordpress.org/Validating_Sanitizing_and_Escaping_User_Data