Ultimate guide to using the WordPress Advanced Custom Fields plugin. Presented by Andrew Marks at the Brisbane Northside WordPress Meetup on 14th November 2018.
2. What are Custom Fields?
• Custom fields are a form of meta data that
can be used to extend posts and pages (&
CPTs).
• An example of a custom field might be a Star
Rating plugin, which assigns a rating between
1 and 5 to your posts.
5. Examples of Custom Fields
• Setting an expiration date for posts
• Reference Links and Contributors
• Adding a CSS Class for styling
• Location taxonomy (like Category / Tag)
• Who’s used Custom Fields (or ACF)?
• Uses?
6. How Does WP Handle Custom Fields?
• While editing a Page or Post,
you can add custom fields.
• Select a field (or enter a new
one) then enter the value
• Custom Fields are added on a
per-post basis
• You need to write code to
extract the value and display it.
7. How Does ACF Handle Custom Fields?
• Custom fields are pre-defined on a per-
post type basis
• There are more than 20 different fields to
choose from, not just a test box
• You still need to write code to
extract the value and display it.
8. Types of Custom Fields
• Text
• Text Area
• Number
• Email
• Password
• WYSIWYG
Editor
• Image
• File
• Select
• Checkbox
• Radio Button
• True / False
• Page Link
• Post Object
• Relationship
• Taxonomy
• User
• Google Map
• Date Picker
• Color Picker
• Message
• Tab
• Plus Premium fields…
9. How To Use The Plugin
1. Create A New Field Group
10. How To Use The Plugin
2. Add &Configure
Fields
Enter Label, Name, Type,
Instructions, Required,
Default Value, Placeholder,
Prepend, Append, Formatting
Character Limit, Conditional
Logic, Min / Max Value
and/or Step Size!
11. How To Use The Plugin
2. Add &Configure Fields (example)
12. How To Use The Plugin
3. Configure Field Location and Options
Options: Order number, Position, Style and Hide on Screen
13. How To Display Custom Fields
• In order to display custom fields on your site,
you need to call them in a template file.
• This will require coding, and a knowledge of
the WordPress template hierarchy…
15. How To Display Custom Fields
For example:
• Check which template is available: single.php,
or singular.php, or simply index.php
• Copy the file to your Child theme, and rename if
necessary: single-post.php
• Add your code to this new file
16. Accessing the Custom Fields
• WordPress provides a function
get_post_meta()
$expirationtime = get_post_meta($post->ID,
"expiration", false);
• It’s recommended you use ACF’s function
the_field() instead
the_field('expiration');