Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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