Use Advanced Custom Fields PRO Repeater field in an options page to make a list of information easy for a client to maintain for easy rendering in multiple formats.
I am in the middle of converting a client site from static html to WordPress. One page lists the services provided by the client as a simple list. I proposed changing the list to a grid with hover effects.
I ported the services list into the code used in the Codrops Hover Effects demo. A few days later the client requested changes in the list order and content. This was a bit tedious in the new page. It was then that I decided to convert the list data into a format that the client can easily editor.
Advanced Custom Fields PRO
I have a Developer license of Advanced Custom Fields PRO so I decided the use the Repeater Field feature.
When I began creating the Field Group for the services I needed a Location rule – where to display the edit section. I wanted to use the services information on multiple pages so I couldn’t set the Location rule to be a page. I decided to attach it to an options page.
I populated this Field Group with a Repeater field with two text fields (service name and service description) and then entered the data.
Retrieve Data
The data is stored in the wp_options table. Retrieving the data was very similar to retrieving regular repeater field data – just add the ‘options’ parameter to the have_rows() function.
Now I can retrieve the data wherever I need. For the simple list I will just wrap the info in ul/li markup and the more complicated markup for the grid with hover effects. It will be easy for the client to maintain and change the order of the services.
Leave a Reply