-
Notifications
You must be signed in to change notification settings - Fork 11
Example: Edit Shortcuts
Jörn Lund edited this page Oct 27, 2018
·
2 revisions
Adding an edit shortcut to the themes HTML output can be achieved by calling one of the acf_customizer_field
, acf_customizer_row
or acf_customizer_sub_field
actions.
Let‘s assume you output some field somewhere in your theme.
the_field( 'some_field' );
The same with an edit shortcut added:
do_action( 'acf_customizer_field', 'some_field' );
the_field( 'some_field' );
Outside the Loop you need to pas the post id too:
do_action( 'acf_customizer_field', 'some_field', 123 );
the_field( 'some_field', 123 );
Inside a repeater or layout field:
while ( have_rows('repeatable_field') ) {
the_row();
// This will create a shortcut to the entire repeater
do_action( 'acf_customizer_row' );
the_sub_field('repeated_field');
// That on creates a shortcut directly to the input of 'repeated_field'
do_action( 'acf_customizer_sub_field', 'repeated_field' );
}