Created
July 29, 2019 17:05
-
-
Save stephanieleary/b0f6ef8e6dd299bff7285063536db4c1 to your computer and use it in GitHub Desktop.
Print all ACF fields in a group with labels and values
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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