Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jamiemitchell/cf946173df78fd3d61957c13334e5e86 to your computer and use it in GitHub Desktop.
Save jamiemitchell/cf946173df78fd3d61957c13334e5e86 to your computer and use it in GitHub Desktop.
<?php
/**
* Template Name: Testimonials - ACF Functions
*/
add_action( 'genesis_entry_content', 'prefix_output_testimonials' );
/**
* Output ACF testimonials.
*
* @link https://acfextras.com/simple-testimonials-repeater-field/
*/
function prefix_output_testimonials() {
if ( have_rows( 'testimonials' ) ) :
echo '<div class="testimonials">';
while ( have_rows( 'testimonials' ) ): the_row();
$testimonial = get_sub_field( 'testimonial' );
$image = get_sub_field( 'image' );
$byline = get_sub_field( 'byline' );
if ( $testimonial ) {
echo '<div class="testimonial">';
echo '<div class="testimonial-content">';
if ( $image ) {
echo '<div class="testimonial-image alignright">';
echo wp_get_attachment_image( $image, 'thumbnail' );
echo '</div>';
}
echo wp_kses_post( $testimonial );
echo '</div>';
if ( $byline ) {
echo '<div class="testimonial-byline">' . esc_html( $byline ) . '</div>';
}
}
echo '</div>';
endwhile;
echo '</div>';
endif;
}
genesis();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment