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

WordPress

Christopher Paccione
Christopher Paccione
14,831 Points

single-work.php (loop error)

Hello everyone,

I'm having an issue with the "How to Build A Wordpress Theme" project.

I've watched videos more than a fews times, but I can't find my error. When I click on the the "view project" button I receive a loop error. I think the error is on the my single-work.php page, but I can't find it myself.

I have no clue on how to attach screenshots or if that's possible on the forum, if it is I'll attach them.

Thank you!

<?php get_header(); ?>

<div class="grid_12 omega clearfix">

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    <h3><?php the_title(); ?></h3>
    <div class="intro"> 
        <p><?php the_field('description' ); ?></p>
    </div>

    <p><a class="btn blue" href="<?php the_field( 'url' ); ?>" style="background-color: <?php the_field( 'button-color' ); ?>">View Project &rarr;</a></p>

    <hr>

    <div class="project-images">

        <?php the_field( 'project_images' ); ?>

    </div>


    <?php endwhile; else: ?>

        <p>There are no posts or pages here.</p>

<?php endif; ?>

</div>

<?php get_footer(); ?>

3 Answers

Christopher Paccione
Christopher Paccione
14,831 Points

As a follow up; I've read through the forum to see how others who have encountered my issue resolved the problem, but I've accounted for the the name of the php, and I've made sure the custom post type is "work".

Christopher Paccione
Christopher Paccione
14,831 Points

Update, my single-work.php only worked (pun intended) when I changed my permalink structure to "default".

Why is that?

p.s. - I realize now I should have edited my first query to the forum instead of answering myself twice. I'll fix that going forward.

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

Hey Christopher Paccione! This happens because the template structure works off of both the custom post type and page slugs :)

Christopher Paccione
Christopher Paccione
14,831 Points

Hey Zac, Thanks for the follow up! The videos have been really helpful, and especially the blog you did on bootstrap for wordpress (that saved me with a client of mine).

I'm unfortunately not following you on how to fix the link if I have permalinks set to "post name". I'm quite new to wordpress developing.

Thanks!