Advanced Custom Fields : Plugin

Hi there, This post is about a plugin I’ve used for extending the functionalities of the WordPress. The Plugin name is Advanced Custom Fields. This plugin provides many features to extend the power of WordPress. There is also an inbuilt functionality in WordPress for adding custom fields for any post but it offer a little power to customize the WordPress.

This Plugin can make content of a website fully dynamic. From Basic field types i.e. Text, Email, Number etc to a jQuery Color/Date Picker it can be useful for many things. There is a lot of Documentation available for the plugin in their Official Website.

It’s admin panel is same as a Post type with a heading Field Groups from where we can create groups of Fields and set up rules for the specific Field Group. You can add many field type eg. Basic, Content, Choice, Relational etc.

The most interesting field types I like is the category jQuery. You can add a Date Picker, Color Picker and a Google Map without any extra coding. In a project I have to add an icon and a color to the categories for the Blog Posts. There are many plugins out there who can add icon functionality to the Categories, but for adding colors for a category there is no plugin. So by the help of this plugin i have added a custom icon and custom color feature to the Categories Section.

Another Feature I like is Relationships. If you use this field you will have a nice post picker. You can set if you want to return the Post ID, Post Obj or for images it can be Post Link.

You can set rules for the location you want to add the Custom Field. In Image you can view the set of rules for a particular set of field types. We can set rules in Logical Way (Add/Or).

Location Feature in ACF
Location Feature in Advanced Custom Fields

We can also select items to hide them from the edit screen. I have created a Settings page in my theme where i just want the title only in the page and the Custom Fields I have added so i have selected all the options to hide on the edit screen.

 

Options tab in ACF
Options tab in Advanced Custom Fields

 

Settings Page
Settings Page

Adding Code to Theme: As in the Custom Fields they will not show up on the Front end, For showing Values added by Advanced Custom Fields to the Front End we have to  add some code in the Theme. For getting values added for Post types is very easy, We just have to use get_field(‘field_name’) or the_field(‘field_name’). But for other setting like for categories we have to change parameters of get_field eg. category type followed by tag id and field name ex. get_field(‘category_type_tag_id’, ‘field_name’).

There is an another feature available for separating the fields from one another. Like if we want our website to be more dynamic and having many custom fields for updating values we can end up with a nasty edit screen. So for making a good UX we can add tabs layout for making it easily manageable.

Let say I want to use three custom fields with every post eg. Resources, Related Post and Other Contributors. So Resources may be the Simple text with links, Related posts are the Relationships of the Posts and the Contributors are the array of the users. We can create a Single Field Group. And By adding Tabs in between It can be more Attractive.

Custom Post Options
Custom Post Options

Exporting: This feature is the best feature i liked in this plugin. You can either export it in XML or in PHP. First I didn’t understand why Export to PHP option is there but when I used it I liked it.

Let say in a project for a client we are using lots of Advanced Custom Fields. And we don’t want that user may have the power to change or add the extra custom fields. In that case we can include Advanced Custom Fields to the theme itself and hide its UI from the Client. By this the Custom Fields UI will not appear in the Admin Panel, so that the clients can’t alter the Fields we have created for them. We just have to go to the Export to PHP option page and we will have all the instructions to how can we include Advanced Custom Fields and the Field Groups in theme itself.

I have used Advanced Custom Fields in this theme also. For adding Upcoming Articles and Related Posts with any post. You can Find them in the Sidebar.

3 Replies to “Advanced Custom Fields : Plugin”

  1. Pingback: my blog
  2. Pingback: lace frontal

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.