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 | |
/** | |
* Template Name: Testimonials - Native Functions | |
*/ | |
add_action( 'genesis_entry_content', 'prefix_output_testimonials' ); | |
/** | |
* Output ACF testimonials. | |
* | |
* @link https://acfextras.com/simple-testimonials-repeater-field/ | |
*/ | |
function prefix_output_testimonials() { | |
$post_id = get_the_ID(); | |
$count = get_post_meta( $post_id, 'testimonials', true ); | |
if ( ! $count ) { | |
return; | |
} ?> | |
<div class="testimonials"> | |
<?php for ( $i = 0; $i < $count; $i ++ ) { | |
$testimonial = get_post_meta( $post_id, 'testimonials_' . $i . '_testimonial', true ); | |
$image_id = get_post_meta( $post_id, 'testimonials_' . $i . '_image', true ); | |
$byline = get_post_meta( $post_id, 'testimonials_' . $i . '_byline', true ); | |
if ( $testimonial ) { ?> | |
<div class="testimonial"> | |
<div class="testimonial-content"> | |
<?php if ( $image_id ) { ?> | |
<div class="testimonial-image alignright"> | |
<?php echo wp_get_attachment_image( $image_id, 'thumbnail' ); ?> | |
</div> | |
<?php } ?> | |
<?php echo wp_kses_post( $testimonial ); ?> | |
</div> | |
<?php if ( $byline ) { ?> | |
<div class="testimonial-byline"><?php echo esc_html( $byline ); ?></div> | |
<?php } ?> | |
</div> | |
<?php | |
} | |
} ?> | |
</div> | |
<?php | |
} | |
genesis(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment