After installing ACF from the plugin directory, you should have a Custom Fields option available in the sidebar. Head over there and add a new field group.
Say, for this example we would like to add a location field to the default post. We’ll name the field group to someone appropriate such as ‘Post’.
Now add a new field. In this section you can choose the field type as well as other options.
The Field label is what it will be referred to in the admin panel. Field name is what you’ll refer this field by in the frontend. I recommend having field names in lowercase and with underscores instead of spaces.
Everything else is optional. Default field type is the text field. If you change the field type, there will be more options available to you specific to that field type.
Now we’ll attach this field group to the default post type. To do this, set the field location filter to ‘Post type’ – ‘is equal to’ – ‘Post’. This should be the default anyways.
Now create a new post(or select an existing one) and there should be a metabox looking like this:
Fill in some text. This will now be available in the frontend.
Now, open the content-single.php template(or whatever template your theme uses for single post type) and paste
<?= get_field('location'); ?> in.
This will show the text you’ve entered in the field inside the backend. This is the basis of how custom fields work and in general, how content management systems work in general.
There’s more to this. You can attach the metabox in the admin sidebar(the one on the right), on the page post type, in your custom post type, even on taxonomies(and custom taxonomies too).
There’s also an option to setup a global ‘options’ page where you can setup commonly use fields.
You can also change their look and positioning inside the field group options, disable the default wysiwyg editor and a bunch of other stuff. This truly opens up new ways of developing your WordPress website.
There are over 20 fields available. Some of the most common ones are:
- button group
- wysiwyg editor
- date time picker
- google map
- flexible content(very useful)
- Repeater(very very useful)
- Post Object
with more on the way.
Of all these, the repeater field is super useful as it allows you to nest field groups. Best of all – you can have unlimited nesting. This is a very powerful capability which is hard to find even in modern CMSs.
Also checkout awesomeacf where you can find 3rd party fields.