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 trialJohannes Terry
Courses Plus Student 505 PointsAdding content in custom places part 2
work.php
<div class="grid_6 spotlight project" style="background-color: <?php the_field( 'background_color' ); ?>">
<a href="<?php the_permalink(); ?>">
<img src="<?php the_field( 'homepage_slider_image' ); ?>">
</a>
<h4>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</h4>
<?php the_field( 'description' ); ?>
<p>
<a class="btn blue" href="<?php the_permalink(); ?>" style="background-color: <?php the_field( 'button_color' ); ?>">
>
View Project →
</a>
<p>
</div>
copied the above to content-work.php. The content in work displays perfectly. then replaced the above in work.php with
<?php get_template_part( 'content', 'post' ); ?>
changed post to work
and end it with
<?php endwhile; endif; ?>
Then the work page doesn't display the work neither does it display on front page.
I followed the video and did exactly what's on the video but no luck.
10 Answers
Zac Gordon
Treehouse Guest TeacherCan you post up the full content for your work.php page and your front-page.php please.
Use this post to format your code: https://teamtreehouse.com/forum/how-to-type-code-in-the-forum
Johannes Terry
Courses Plus Student 505 PointsHere is the front-page.php
<?php get_header(); ?>
</div>
<div class="container-wrap">
<div id="featured" class="clearfix flexslider">
<ul class="slides">
<?php
$args = array(
'post_type' => 'work'
);
$the_query = new WP_Query( $args );
?>
<?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<li style="background-color: <?php the_field( 'background_color' ); ?>">
<div class="container">
<div class="grid_8">
<img src="<?php the_field( 'homepage_slider_image' ); ?>" alt="<?php the_title(); ?> Project Screenshot">
</div>
<div id="featured-info" class="grid_4 service omega">
<h5>Services and Programs</h5>
<h4><?php the_title(); ?></h4>
<p><?php the_field( 'description' ); ?></p>
<a class="btn blue " style="background-color: <?php the_field( 'button_color' ); ?>" href="#">Read more →</a>
</div>
</div>
<?php endwhile; endif; ?>
</li>
</ul>
</div>
<div class="container clearfix">
<div class="grid_11 omega feature-article">
<h5>Featured Article</h5>
</div>
<?php
$args = array(
'post_type' => 'post',
'category_name' => 'featured',
'posts_per_page' => 1
);
$the_query = new WP_Query( $args );
?>
<?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<div class="push_2 grid_11 omega clearfix">
<article>
<?php get_template_part( 'content', 'post' ); ?>
</article>
</div>
<?php endwhile; endif; ?>
<div class="grid_12 omega clearfix">
<div class="grid_10 ">
<article>
<h5>Recent Article</h5>
<?php
$args = array(
'post_type' => 'post',
'cat' => -1,
'posts_per_page' => 1
);
$the_query = new WP_Query( $args );
?>
<?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<?php get_template_part( 'content', 'post' ); ?>
<?php endwhile; endif; ?>
</article>
</div>
</div>
<?php
$args = array(
'post_type' => 'work'
);
$the_query = new WP_Query( $args );
?>
<?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<?php get_template_part( 'content', 'work' ); ?>
<?php endwhile; endif; ?>
<?php get_template_part( 'content', 'testimonials' ); ?>
</div>
</div>
<?php get_footer(); ?>
Johannes Terry
Courses Plus Student 505 PointsHere is work.php
<?php get_header(); ?>
</div>
<div class="container-wrap">
<div id="featured" class="clearfix flexslider">
<ul class="slides">
<?php
$args = array(
'post_type' => 'work'
);
$the_query = new WP_Query( $args );
?>
<?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<li style="background-color: <?php the_field( 'background_color' ); ?>">
<div class="container">
<div class="grid_8">
<img src="<?php the_field( 'homepage_slider_image' ); ?>" alt="<?php the_title(); ?> Project Screenshot">
</div>
<div id="featured-info" class="grid_4 service omega">
<h5>Services and Programs</h5>
<h4><?php the_title(); ?></h4>
<p><?php the_field( 'description' ); ?></p>
<a class="btn blue " style="background-color: <?php the_field( 'button_color' ); ?>" href="#">Read more →</a>
</div>
</div>
<?php endwhile; endif; ?>
</li>
</ul>
</div>
<div class="container clearfix">
<div class="grid_11 omega feature-article">
<h5>Featured Article</h5>
</div>
<?php
$args = array(
'post_type' => 'post',
'category_name' => 'featured',
'posts_per_page' => 1
);
$the_query = new WP_Query( $args );
?>
<?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<div class="push_2 grid_11 omega clearfix">
<article>
<?php get_template_part( 'content', 'post' ); ?>
</article>
</div>
<?php endwhile; endif; ?>
<div class="grid_12 omega clearfix">
<div class="grid_10 ">
<article>
<h5>Recent Article</h5>
<?php
$args = array(
'post_type' => 'post',
'cat' => -1,
'posts_per_page' => 1
);
$the_query = new WP_Query( $args );
?>
<?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<?php get_template_part( 'content', 'post' ); ?>
<?php endwhile; endif; ?>
</article>
</div>
</div>
<?php
$args = array(
'post_type' => 'work'
);
$the_query = new WP_Query( $args );
?>
<?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<?php get_template_part( 'content', 'work' ); ?>
<?php endwhile; endif; ?>
<?php get_template_part( 'content', 'testimonials' ); ?>
</div>
</div>
<?php get_footer(); ?>
Zac Gordon
Treehouse Guest TeacherInteresting. At first glance it looks right, but you're saying nothing shows up on the Work page?
Johannes Terry
Courses Plus Student 505 PointsYeah, if you can just read what I have at the beginning of the forum. There is the problem. Is that part of your video where you ask us to go to work-content php and copy the code and paste it on work.php....
Zac Gordon
Treehouse Guest TeacherI think you should be including a different loop that content post. Try linking to loop-portfolio.php
Johannes Terry
Courses Plus Student 505 Pointsi noticed I don't have portfolio.php, but I don't recall you stating on the video to create that file.
Zac Gordon
Treehouse Guest TeacherNo just loop-portfolio.php. That was the file we placed the loop for the work items into. It looks like you're including the loop for the posts instead, which would cause them to not display. Try taking the loop from work.php and putting it into a file loop-portfolio.php and including that. It should work :)
Johannes Terry
Courses Plus Student 505 PointsI copied what was in work.php and put it in loop-portfolio.php and it didn't work :(
Johannes Terry
Courses Plus Student 505 PointsI did the tutorial like 3 times now and the work area never appears. Still same problem and on the video it does not say to create afile called loop-portfolio.php. I'm lost and confused.