Advanced Custom Fields (ACF) is a popular WordPress plugin that allows you to easily create custom fields for your WordPress website. It’s a powerful tool that enables you to add additional information to your posts, pages, and custom post types, giving you more control over your content. In this tutorial, you’ll learn how to use Advanced Custom Fields in WordPress, including examples of code you can use on your website. Editing your website’s code requires some knowledge of accessing files on your server and editing the code in those files. Remember, always backup your website before making any changes.
Table of Contents
To get started, you first install and activate ACF. Follow our step-by-step guide for installing and activating plugins if you need help with this.
Create New Field Group
- After installing the plugin, go to “ACF > Field Groups”
- Then click “+ Add New” on the top left
- Finally, add a name to your field group on the top left. This will describe where the field group will be used so you can easily find it later
Add Fields
- Once you have created the field group, you can now add some fields. When creating a new group, you will see a new field is automatically created. You can also click “+ Add Field” to add an additional field
- Next select your field type

ACF field types There are several different types of fields to choose from, including:
- Text – This field type allows you to create a simple text field where users can enter a single line of text. Text fields are likely the field type you will use most often.
- Textarea – Similar to the Text field, this field type allows you to create a larger text area where users can enter multiple lines of text.
- Number – This field type allows you to create a field where users can enter a number. You can choose the minimum and maximum values along with the step value which determines how much a user can increase the field.
- Email & URL – These fields validate that the text entered is an email address or URL.
- Image – This field type allows you to create a field where users can select an image from the media library or upload a new one.
- File – Similar to the Image field, this field type allows you to create a field where users can upload a file. This can include any type of file and you can restrict which file types allowed.
- WYSIWYG Editor – WYSIWYG Editor allows you to create a rich text editor where users can enter formatted text, images, and other content. You would use this field instead of Textarea if you want to be able to add formatting and images.
- Select – A dropdown list where users can select an option from a list.
- Date Picker – Date Picker allows you to create a field where users can select a date.
- Color Picker – A field where users can select any color from a palette.
- Group – This is a Layout field. Layout fields allow you to change the format of how the fields will display. You can use the group field type to divide other fields into sections. For example, if you are creating a field group for a home page, you would create a group field type called “Intro”. The “Intro” group would contain the fields for an intro section on the website such as the title, images and text.
- Once you select your field type, add the label. When you add a label, the “name” will be automatically generated. You can modify the name, but it cannot include spaces, only dashes and underscores. You will use the name to access the field content later
- In addition to the type and label, you can set the Validation, Presentation and Conditional Logic settings. These settings will be different for each field type you create, and most of the time, you will not need to modify any of these
Field Group Settings
The field group settings are how you determine where your field group will display and how it will look.
Location Rules
- First, scroll to the bottom of the page and find “Settings > Location Rules”
- Then select where you’d like the field to show

Location Rules Type There are a lot of options to select from, but the most common are:
- Post Type – In WordPress, just about everything is considered a “Post”. This includes Posts, Pages and Products. If you want your field group to show on all posts of a certain type, select this.
- Post and Page Template – If your website has been professionally built on a custom theme, you will have different templates that control the layout and styling of specific pages or posts. If you want your field group to show on a specific template, choose one of these two options.
- Post Category and Taxonomy – Posts can be assigned a category or a taxonomy like a “tag”. This option will add the field group to different categories or taxonomies.
- Post or Page – Select this option to display the field group on a specific post or page.
- Now, select the other settings that will determine where the field group will show. In the example below, I selected the field group to show if a “Page Template” “is equal to” “Home”. That means this field group will show on any page that uses the page template called “Home” and nowhere else. You could also choose “not equal to” to show the field group on every page that does not use the “Home” page template
Presentation

The Presentation settings will determine how the field group is displayed along with other items on the page that this field group is displayed on, including:
- Style – Select whether to include a box around the field group (Standard) or not (Seamless).
- Position – This determines where the field will show on the page. “High” will place the field group directly below the title and permalink. “Normal” puts the field group below most of the default fields. “Side” places the field group on the right side of the page like the “Publish” metabox.
- Order Number – If you have multiple field groups on the page, this will determine which shows first.
- Hide on Screen – This allows you to hide certain default fields on the page. If you are adding a lot of custom fields to a page, you will probably want to hide the “Content Editor” field since you will not be displaying this content on the page’s front-end.
Group Settings

Here you can choose to deactivate the field group, allow the field group to be accessible through the API and add a description.
Using the Fields
Now that your field group is setup, it’s time to use it. In this example, we will be using WiscWebs’ Home page hero as an example:


- After that, open the file that is used to display the page or section using an FTP client like Filezilla and a text editor like Notepad++.
- To display a single field that is not part of a layout group, you should use:
<?php if( get_field( 'title' ) ) { the_field( 'title' ); } ?>First, we check if there is any content in the field using “get_field( ‘title’ )”. This will return false if the field is empty and the “if” statement will fail. If there is content in the field, “the_field( ‘title’ )” prints the content.
- On the other hand, if your fields are part of a group, like in our example, we can access them with:
<?php if( have_rows( 'hero' ) ) { while ( have_rows( 'hero' ) ) { the_row(); ?> <div class="home-hero d-flex align-items-center justify-content-center" style="background-image:url('<?php the_sub_field( 'background_image' ); ?>');"> <div class="text-center text-white"> <h1><?php the_sub_field( 'title' ); ?></h1> <p><?php the_sub_field( 'sub_title' ); ?></p> </div> </div> <?php } } ?>In this case, we first check if there is any content in any of the fields in the group “hero” for this page using “have_rows( ‘hero’ )”. If there is content in the field group, we then create our HTML structure and add the content from our fields. Since we are accessing fields within a group, we use “the_sub_field()” instead of “the_field()”. The field “background_image” is an image field type that returns the URL of the image to be used as a background. The fields “title” and “sub_title” are text fields.
The end result from the example above can be seen as the first section on WiscWebs’ homepage (a couple buttons have been added to the section since this article was written). If we ever want to change the image or text on that section, we can simply change the fields while editing the page. There is no need to modify the code in the template file any further, and anyone can make these changes.
Final Thoughts
Now you know how to use Advanced Custom Fields in WordPress and should have all knowledge you need to get started with ACF on your website. This tutorial included creating, configuring and displaying custom fields. We didn’t cover all the features of ACF, but you should now have an idea of how powerful using the plugin on your website will be. If you’re looking for a truly custom website that utilizes ACF, we can help. Let’s chat.












