Giving clients an easy way to update content on their site is crucial. The edit-button component is aiming to make this process as easy as possible, giving users a straight-forward way to edit Advanced Custom Fields and WordPress options from the front-end.
Updates are being sent via AJAX, making this a solution that works without the need for a reload.
Currently, the edit-button component supports following fields:
We are hard at work to support more extend the list of supported field types (images etc.) in the future.
To enable front-end editing, just add the spx-edit-button component to a page. After that, you have to mark all elements that you want to be editable on the site. This is done by adding the data-spx-edit attribute to existing text elements:
The wp_options or ACF field name has to be the value of the attribute. After that, you're good to go!
Of course, showing the button to every page visitor makes no sense, so it is advisable to only render the button if a user is logged in.
Starting with version 2.2.0, it is now possible to edit multiple different data types using one edit-button component like so:
Advanced Custom Fields includes various useful fields, one of them being the classic repeater field which makes adding repeating content a breeze.
Editing sub fields is also possible using the edit-button element with a slightly adjusted setup. Let's loop through a repeater instance and add the correct data-attributes:
So what is exactly happening here? The markup is similar to standard fields with a couple of exceptions, a data-spx-edit-subfield has to be added to each repeater entry and the data-spx-edit attribute has to be filled with an array like structure that follows the update_sub_field pattern:
This has the advantage that even deeply nested repeater fields can be targeted and updated using the edit-button component.
A collection of web components
for WordPress developers.
A modern component-like
ACF blocks framework.
A minimal and feature-packed