Last active
December 29, 2017 17:09
-
-
Save jtsternberg/d66affbfa4671e927f59a47468d949aa to your computer and use it in GitHub Desktop.
repeatable field fetching
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 | |
$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