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 trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Torbjörn Sjögren](https://secure.gravatar.com/avatar/76176675f4cdbd1942b235fabf736064?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Torbjörn Sjögren
Courses Plus Student 1,621 PointsCode tip: Repeater field for displaying project images.
Hi Watching 'How to Build a WordPress Theme' course , video: 'http://teamtreehouse.com/library/websites/how-to-build-a-wordpress-theme/converting-static-code-into-wordpress-templates/convert-custom-post-type-details-template
Just wanted to share an alternate way to display project images with the 'repeater field' add-on: http://www.advancedcustomfields.com/add-ons/repeater-field/
I think its a better admin experience for the user and easier to style/code. The drawback is that its a payed add-on.
Here is a code snippet for single-work.php that loops through all added images and displays them using 'wp_get_attachment_image':
<div class="project-images">
<?php if ( get_field( 'work_project_images' ) ): ?>
<?php while ( has_sub_field( 'work_project_images' ) ): ?>
<?php
$image_id = get_sub_field( "work_project_image" );
echo wp_get_attachment_image( $image_id, large); //The image without link
//echo wp_get_attachment_link( $image_id, large); //The image whith link
?>
<?php endwhile; ?>
<?php endif; ?>
</div>
Sorry for the code styling. Just couldn't format it right in this forum post. [Edit] Fixed now (with code fences)
1 Answer
![Zac Gordon](https://secure.gravatar.com/avatar/de0a01122ca4a619004332ab04431b7b?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Zac Gordon
Treehouse Guest TeacherGreat suggestion!!! Thanks for sharing :)
What are your thoughts about beginning to suggest that people use Gists to share PHP code instead of directly on the forums? It is a little tricky to do the 4 character indent for each line of code.
![James Barnett](https://secure.gravatar.com/avatar/43ea08b4fc547e8a5da87c207bea2123?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
James Barnett
39,199 PointsGists work, you can also use a PHP Playground or use codepad.org
![James Barnett](https://secure.gravatar.com/avatar/43ea08b4fc547e8a5da87c207bea2123?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
James Barnett
39,199 PointsAlso instead of using 4 spaces I always use code fences, which I wrote a post about once
https://teamtreehouse.com/forum/how-to-type-code-in-the-forum
![Zac Gordon](https://secure.gravatar.com/avatar/de0a01122ca4a619004332ab04431b7b?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Zac Gordon
Treehouse Guest TeacherHot dang, I like them code fences right there. That's my solution.
As for a third party embedable type thing, I'm thinking Gist out of these options. Would also git more students on Github too, which is good.
![James Barnett](https://secure.gravatar.com/avatar/43ea08b4fc547e8a5da87c207bea2123?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
James Barnett
39,199 PointsI love code fences because there's syntax highlighting support for them which makes them easier to read.
![Torbjörn Sjögren](https://secure.gravatar.com/avatar/76176675f4cdbd1942b235fabf736064?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Torbjörn Sjögren
Courses Plus Student 1,621 PointsOK code fixed using code fences. James Barnet I think that your guide should be sticky in this forum and i think that those options should show when clicking 'Markdown Cheatsheet' or via link. This is a "Code heavy" forum and it should be clear/easy to enter code. Its OK with external services but i rather not use i Gist for code that i know is wrong (as in most questions here). OK for students to adopt GitHub though (just starting out myself). OK with third party solution but its best to have all content in this forum.
So... Please give the forum users more info on how to enter code. Clear instructions via link below text area would be best. Thanks ;-)
Torbjörn Sjögren
Courses Plus Student 1,621 PointsTorbjörn Sjögren
Courses Plus Student 1,621 PointsJust a note. This code requires the 'return value' in image field set to 'Image ID'.