How to use ACF Text Field
ACF text field creates a extra text input field. This is a basic text input. When you want to create a new field for any post, page, user or forms, you can create the field and assign it to.
Lets see how to use this field:
- Post Type
- Post Template
- Post Status
- Post Format
- Post Category
- Post Taxonomy
- Page Template
- Page Type
- Page Parent
- Current User
- Current User Role
- User Form
- User Role
- Menu Item
ACF Text Field Example
Lets discuss this with an real world example. Assume you want to create a Sub Title for every page in the website. We can achieve this really easy with ACF.
As you have already installed the Advanced Custom Fields plugin, go to
Custom Fields menu first. Then add new.
I am going to name it as
Sub Title. Because I am using the same for all the pages.
When you’re in the page:
- Click on
- Give the field name. I gave the field name as
- Add the rule group as below.Select the rules in
Locationsection. You can add any number of rules to get your work done.
- In settings section you can make the changes. As Sub Title is priority I’ll show it is just after the title. To do that I want to go to settings and change the
High (after the title).
- Lets see how it appears in the page.
About Pagecode looks.
Open up the about page template for editing. And code it as below.
<?php the_field('sub_title'); ?>
This code lets you to output the given sub title.
- Here is how it looks in front end.
You can use the same for the Text Area and some other fields as well. settings and front end coding methodology sightly different for some fields. Most of them are in ACF Pro plugin.
We are done. Thanks for reading. Hope you enjoyed the tutorial. Happy learning ahead.