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 trialChelsey Beck
1,905 PointsProblem with the Work page
I am working on "How to Build a WordPress Theme" and I am stuck on "Displaying Custom Posts and Fields in a Template. I have followed along carefully. The problem is that when I click on the "Work" link, it displays "Posts" instead of "Work". Though, it shows that I am indeed in the work.php file. Something must be going on in the PHP for WordPress to default to posts, but, I cannot figure it out.
Here is the code:
<?php
/*
Template Name: Work Page
*/
get_header(); ?>
<p>This is the work.php file.</p>
<?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() ; ?>
<h3><?php the_title() ; ?></h3>
<?php the_field( 'description') ; ?>
<hr>
<?php endwhile; else: ?>
<p>There are no posts or pages here.</p>
<?php endif; ?>
<?php get_footer(); ?>
Any ideas? Thanks in advance!
1 Answer
Chelsey Beck
1,905 PointsI figured it out. It was 'post-type' on line 16...should have been 'post_type'. Thanks anyway!