Skip to main content

benecaster_get_episode_custom_fields()

Custom Fields Free
benecaster_get_episode_custom_fields( int $episode_id ): array

Returns every custom field value on an episode as one list — the fields from the field groups attached to episodes on the Fields screen, which are the fields the episode page shows. Use it to render them all without looping over each group yourself.

Parameters

Name Type Default Required Description
episode_id int — Yes The episode (post) ID.

Return Value

Type: array

A flat list of [ 'key', 'label', 'type', 'value', 'group' ] arrays, one per field that has a value, in field-group order and then field order. Every key is always set: key is the field's key and group its field group's name.

Example

foreach ( benecaster_get_episode_custom_fields( get_the_ID() ) as $field ) {
    printf(
        '<dt>%s</dt><dd>%s</dd>',
        esc_html( $field['label'] ),
        esc_html( is_array( $field['value'] ) ? implode( ', ', $field['value'] ) : (string) $field['value'] )
    );
}

Notes

Only fields with a value are included. An empty list means the episode has no custom field values, not that something failed.

There is no ACF integration. Fields created with another plugin are not returned.

To read one field by key, use benecaster_get_fields().

Need this built rather than just documented? See our services →