Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialPeter Simmons
13,295 PointsRelated testimonials
Hi i'm trying to go though all the videos to see if i have missed the part were you connected the related testimonials to the work page? At the moment the testimonials are randomly placed on the work single page but i thought the testimonial would be linked to a particular work post. If i haven't missed the particular video, why is it mentioned in the custom field setup, and could you direct me to the right code to help achieve this? If it is mentioned somewhere, could you direct me to the right video as i cant find it
Chris James
19,102 PointsI mostly have this working now. The information here helped me to get the related testimonials onto my work page
2 Answers
Jahan Zeb
11,169 PointsThank you Chris James, Your link helped me to have it done!
Harry Fox
5,571 PointsSomething like this should go at the bottom of the single-work.php file:
<?php $posts = get_field('related_testimonials');
if( $posts ):
?>
<ul>
<?php foreach( $posts as $post): // variable must be called $post (IMPORTANT) ?>
<?php setup_postdata($post); ?>
<div class="testimonial col-xs-12 col-md-10 col-md-offset-1">
<blockquote>“<?php the_field('testimonial') ;?>”</blockquote>
<cite>— <?php the_field('name') ;?></cite>
</div>
<?php endforeach; ?>
</ul>
<?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
<?php endif; ?>
Chris James
19,102 PointsChris James
19,102 PointsI'm searching for this too