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

Single Project View

Hi, I'm doing "How to Build a Wordpress Theme" and I'm having some trouble with custom post types when he uses it for Work page. How do I link a project to that single view page? Here's my code but it's not working. The browser is giving me an error.

<?php 

/*

Template Name: GSA Portfolio Page

*/

get_header(); ?>

<div id="middle">

<?php

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

$the_query = new WP_Query( $args );

?>

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

    <span id="page-headings"><a href="<?php the_permalink() ;?>"><?php the_title(); ?></a></span>


    <div class="entry-thumbnail"><?php the_post_thumbnail(); ?></div>

    <div class="entry-content"><?php the_field( 'address' ); ?></div>

    <?php endwhile; else: ?>

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

    <?php endif; ?>


</div>

<?php get_footer(); ?>

2 Answers

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

Do you have a single-gsaportfolio.php page setup?

I actually figured out what was wrong. What you said plus I had put a space between gsa and portfolio on the Custom Post Types plugin. no0b mistake. I was going to delete this here post but there is no delete button. Sorry! Anyway, I love Wordpress! And thanks for teaching it and thanks for the quick response! :)

Zac Gordon
Zac Gordon
Treehouse Guest Teacher

Yay! +1 to you ;)

And you're very very welcome :)