How To Add Repeater Fields To Your WordPress Posts

Repeater fields are fields that are similar to “Add Another” or “Add More” options for a single field.

For example, you have a custom field named “ingredients”.  If you know exactly how many “ingredients” will always be added (let’s say 4), you could create four separate custom ingredient fields (ingredients_1, ingredients_2, ingredients_3, ingredients_4).  But if the number of ingredients can vary, it would be easier to be able to add additional ingredient fields dynamically.  That would allow you to add as few or as many as you need.

Instead of having to create multiple custom fields, with repeating fields you can reuse the same field.  There are several plugins (both free and paid) that offer repeating fields capability.  Our favorite is Custom Field Suite.  It is an extremely light plugin that created the functionality we wanted without all the unnecessary code and complexity of other plugins.

Creating a repeater field was easy.  Using the example “ingredients” field, here are the steps to create a repeating field.

  1. After activating the plugin, click on the new Field Groups tab
  2. Click on Add New to create a new field group, which will essentially create a new meta box on your post page.
  3. Give this new Field Group a title, which will be displayed on the meta box, and define any other settings you need.
  4. Under the Fields section, click on Add New Field.  Assign it a label and name, and select the Field Type as Loop.  This creates the field container that will hold your repeating field.
  5. Again, click on Add New Field and create the field you would like to use (in our example: ingredients).   You can define the Field Type as text, text area, select, link it to a taxonomy, a user, etc.
  6. There are also several setting options including placement options where you can limit this Field Group to specific Post types, taxonomies, user roles, etc
  7. Once you have created your field and defined any settings you need, click Publish to finish creating this Field Group.
  8. After you have clicked Publish, You will see the two new fields.  Now drag your repeater field (ie ingredients) so that it is nested in the Loop container and click Update.
  9. Test out your new field group by visiting editing or adding a post.

If you used the Drupal module Field Collection, Custom Field Suite is a good option to replicate the same functionality if you are migrating to WordPress.

Available for Amazon Prime