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

Craig Jamieson
Craig Jamieson
19,585 Points

getting the work.php and single-work.php files to work

I was wondering where I find a video that shows me how to get the work.php to load the work posts and then how I link to the single posts when doing the WordPress theme course. I have added in my content. I was certain there was a video, but I've watched so many tutorials over the past few weeks, I might just be getting confused.

5 Answers

Craig Jamieson
Craig Jamieson
19,585 Points

Hi Zac Gordan

I followed your video on the work.php page and I seem to be missing something that I can't spot, cause it doesn't work. I managed to get the single-work.php page to work perfectly, but not the code below ...

...

<?php get_header(); ?>

<div class="clearfix"> <?php

$args = array( 'post_type' => 'work' );

$the_query = new WP_Query( $args );

?>

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

<div class="project"> <a href="<?php the_permalink() ;?>"> <img src="<?php the_field( 'homepage_slider_image' ); ?>"> </a>

<h3><a href="<?php the_permalink() ;?>"><?php the_title() ;?></a></h3> </div>

<?php the_field( 'description' ); ?> <p> <a class="btn blue" href="<?php the_permalink() ;?>"><?php the_title() ;?>View Project →</a> </p>

<?php endwhile; else: ?>

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

<?php endif; ?>

</div>

<?php get_footer(); ?>

...

Craig Jamieson
Craig Jamieson
19,585 Points

F it seems the link to the Markdown Cheatsheet just redirects me to this forum post and when I research it says adding ... before my code is entered will give a code block, but thats not working wither. I do apologies

Craig Jamieson
Craig Jamieson
19,585 Points

Upon further inspection, it seems that regardless of the fact that I can't get my projects listed in my work.php file, I don;t seem to be able to even link it to my work page, so http://mysite.com/work/ doesn;t show the correct template file. Only when I go to http://mysite.com/work.php does it show the correct file, even though it doesn't work.

I have looked in the CPT UI plugin settings and I have setup a Custom Post Type for work, but that doesn't seem to be doing the job I assume it would.

Craig Jamieson
Craig Jamieson
19,585 Points

Resolved the linking to the template issue, now yet to figure out why I can't show my projects in the work.php page