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!

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 WordPress Theme Development Custom Post Type Templates in WordPress The Portfolio Homepage

Andrew Davies
Andrew Davies
6,884 Points

Images not displaying on Portfolio Page and Permalink linking to "Hello World" Post

I'm missing something obvious and vital here but having looked through all the questions on this video I haven't found an answer.

I have two issues that I think must be linked.

Firstly, I cannot get thumbnail images to display on the portfolio page. I have added

"add_theme_support( 'post-thumbnails' );"

to my functions.php file as instructed. The "add_theme_support( 'menus' );" function works fine.

Featured images is enabled and displaying when I add the Portfolio Piece.

In the absence of the image I added a text link which did display but the link address is


and not "http://localhost/localwp.dev/portfolio_wadn/pink-triangle/" (Hello Weezer fans)

So I know I am missing something because the Portfolio page is not finding the right slug/address to link to the post.

Can anyone help, my dog is looking at me strangely because I keep sighing and throwing my hands up in the air. The code I have is below:

functions.php code:


add_theme_support( 'menus' );
add_theme_support( 'post-thumbnails' );

function register_theme_menus () {

            'primary-menu'  => __( 'Primary Menu')

add_action( 'init', 'register_theme_menus');

function wadn_theme_styles() {

    wp_enqueue_style( 'foundation_css', get_template_directory_uri() . '/css/foundation.css' );
//    wp_enqueue_style( 'normalize_css', get_template_directory_uri() . '/css/normalize.css' );    
    wp_enqueue_style( 'googlefont_css', 'http://fonts.googleapis.com/css?family=Asap:400,700,400italic,700italic' );
    wp_enqueue_style( 'main_css', get_template_directory_uri() . '/style.css' );

add_action( 'wp_enqueue_scripts', 'wadn_theme_styles' );

function wadn_theme_js() {

    wp_enqueue_script( 'modernizr_js', get_template_directory_uri() . '/js/modernizr.js', '',  '', false );
    wp_enqueue_script( 'foundation_js', get_template_directory_uri() . '/js/foundation.min.js', array('jquery'), '', true );
    wp_enqueue_script( 'app_js', get_template_directory_uri() . '/js/app.js', array('jquery', 'foundation_js'), '', true );  

add_action( 'wp_enqueue_scripts', 'wadn_theme_js' );


page-portfolio.php code:

    Template Name: Portfolio Page

<?php get_header(); ?>

<section class="row">
      <div class="small-12 columns text-center">
        <div class="leader">

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

          <h1><?php the_title(); ?></h1>

          <?php the_content(); ?>

        <?php endwhile; endif; ?>



    $args = array(
        'post-type' => 'portfolio_wadn'
    $query = new WP_Query ( $args );


<section class="row no-max pad">

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

      <div class="small-6 medium-4 large-3 columns grid-item">
        <a href="<?php the_permalink(); ?>">Test</a>

    <?php endwhile; endif; wp_reset_postdata(); ?>


<?php get_footer(); ?>
Andrew Davies
Andrew Davies
6,884 Points

Found the problem.

Had typed

 'post-type' => 'portfolio_wadn'

When I should have posted

 'post_type' => 'portfolio_wadn'

with an underscore, not a hyphen.

I love coding.

1 Answer

Glenré Charl Labuschagné
Glenré Charl Labuschagné
23,203 Points

I made exactly the same mistake: thanks for sharing!!!