Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
repeatable field fetching
<?php
$entries = get_post_meta( get_the_ID(), 'wiki_test_repeat_group', true );
if ( ! empty( $entries ) ) {
$entries = array_values( (array) $entries );
}
$first_entry_title = '';
$second_entry_title = '';
$first_entry_description = '';
$second_entry_description = '';
$first_entry_image = '';
$second_entry_image = '';
if ( isset( $entries[0]['title'] ) ) {
$first_entry_title = esc_html( $entries[0]['title'] );
}
if ( isset( $entries[0]['description'] ) ) {
$first_entry_description = wpautop( $entries[0]['description'] );
}
if ( isset( $entries[0]['image_id'] ) ) {
$first_entry_image = wp_get_attachment_image( absint( $entries[0]['image_id'] ), 'medium', null, array(
'class' => 'thumb',
) );
}
if ( isset( $entries[1]['title'] ) ) {
$second_entry_title = esc_html( $entries[1]['title'] );
}
if ( isset( $entries[1]['description'] ) ) {
$second_entry_description = wpautop( $entries[1]['description'] );
}
if ( isset( $entries[1]['image_id'] ) ) {
$second_entry_image = wp_get_attachment_image( absint( $entries[1]['image_id'] ), 'medium', null, array(
'class' => 'thumb',
) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.