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:

  • Post Type
  • Post Template
  • Post Status
  • Post Format
  • Post Category
  • Post Taxonomy
  • Post

Page:

  • Page Template
  • Page Type
  • Page Parent
  • Page

User:

  • Current User
  • Current User Role
  • User Form
  • User Role

Forms:

  • Taxonomy
  • Attachment
  • Comment
  • Widget
  • Menu
  • 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.

Create new ACF

I am going to name it as Sub Title. Because I am using the same for all the pages.

Create new custom field

When you’re in the page:

  1. Click on Add Field
  2. Give the field name. I gave the field name as Sub Title
  3. Add the rule group as below.Select the rules in Location section. You can add any number of rules to get your work done.
  4. 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 Position to the High (after the title).
    ACF Position
  5. Publish once done.
  6. Lets see how it appears in the page.
    How ACF Field looks
  7. How About Page code 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.

  8. Here is how it looks in front end.
    How ACF Field output in the 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.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *