Structuring Content in WordPress using Advanced Custom Fields

29
STRUCTURING CONTENT with ADVANCED CUSTOM FIELDS WordCamp Buffalo 2014

description

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!

Transcript of Structuring Content in WordPress using Advanced Custom Fields

Page 1: Structuring Content in WordPress using Advanced Custom Fields

STRUCTURING CONTENTwith ADVANCED CUSTOM FIELDS

WordCamp Buffalo 2014

Page 2: Structuring Content in WordPress using Advanced Custom Fields

Hello!

I’m Jamie Schmid.

EX-DESIGNER, CURRENT WORDPRESS ENTHUSIAST & INFORMATION ARCHITECT

FREELANCE, CORPORATE & IN-BETWEEN

PORTLAND, OR

@jamieschmid

Page 3: Structuring Content in WordPress using Advanced Custom Fields

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

Page 4: Structuring Content in WordPress using Advanced Custom Fields

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!

Page 5: Structuring Content in WordPress using Advanced Custom Fields

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/

Page 6: Structuring Content in WordPress using Advanced Custom Fields

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

Page 7: Structuring Content in WordPress using Advanced Custom Fields

Fields Demo!

Page 8: Structuring Content in WordPress using Advanced Custom Fields

Examples of

ACF in Action

Page 9: Structuring Content in WordPress using Advanced Custom Fields
Page 10: Structuring Content in WordPress using Advanced Custom Fields
Page 11: Structuring Content in WordPress using Advanced Custom Fields
Page 12: Structuring Content in WordPress using Advanced Custom Fields
Page 13: Structuring Content in WordPress using Advanced Custom Fields
Page 14: Structuring Content in WordPress using Advanced Custom Fields

OPTIONS FIELD use case: content that is repeated in various places across the site

Page 15: Structuring Content in WordPress using Advanced Custom Fields
Page 16: Structuring Content in WordPress using Advanced Custom Fields

REPEATER FIELD use case: content whose format is repeated numerous times on a page

Page 17: Structuring Content in WordPress using Advanced Custom Fields
Page 18: Structuring Content in WordPress using Advanced Custom Fields

REPEATER FIELD use case: easy for user to add their own accordions on a page

Page 19: Structuring Content in WordPress using Advanced Custom Fields
Page 20: Structuring Content in WordPress using Advanced Custom Fields
Page 21: Structuring Content in WordPress using Advanced Custom Fields
Page 22: Structuring Content in WordPress using Advanced Custom Fields

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

Page 23: Structuring Content in WordPress using Advanced Custom Fields

The (Not So Scary) Code

Page 24: Structuring Content in WordPress using Advanced Custom Fields

Basic Field

Conditionals with image and text field

Page 25: Structuring Content in WordPress using Advanced Custom Fields

REPEATER FIELD uses the same syntax as the WordPress loop!

Page 26: Structuring Content in WordPress using Advanced Custom Fields

Content ModelingPlanning 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!

Page 27: Structuring Content in WordPress using Advanced Custom Fields

Admin UXCustom 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

Page 28: Structuring Content in WordPress using Advanced Custom Fields

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

Page 29: Structuring Content in WordPress using Advanced Custom Fields

Questions / Examples?

Thanks :)

Jamie Schmid

@jamieschmid