Skip to content

Instantly share code, notes, and snippets.

@stephanieleary
Created July 29, 2019 17:05
Show Gist options
  • Save stephanieleary/b0f6ef8e6dd299bff7285063536db4c1 to your computer and use it in GitHub Desktop.
Save stephanieleary/b0f6ef8e6dd299bff7285063536db4c1 to your computer and use it in GitHub Desktop.
Print all ACF fields in a group with labels and values
<?php
$fields = array();
$field_group = get_page_by_title( 'GROUP TITLE HERE', OBJECT, 'acf-field-group' );
if ( is_object( $field_group ) ) {
$acf_fields = acf_get_fields_by_id( $field_group->ID );
$fields = wp_list_pluck( $acf_fields, 'label', 'name' );
}
foreach ( $fields as $field_name => $field_label ) {
printf( '<b>%s:</b> %s', $field_label, get_field( $field_name ) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment