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 WordPress Theme Development Custom Post Type Templates in WordPress Coding Your Own Custom Post Type Templates

Thumbnails not appearing after inclusion of add_theme_support( 'post-thumbnails'); to functions.php file.

Here's my functions.php file:

<?php

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

    function register_theme_menus() {

            register_nav_menus( 
                array(
                    'primary-menu' => __( 'Primary Menu' )
                ) 
            );
    }

    add_action( 'init', 'register_theme_menus' );

    function wpt_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', 'wpt_theme_styles' );

    function wpt_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);
        //pass jquery.js & foundation.js to array param, causing both to load first
        wp_enqueue_script( 'main_js', get_template_directory_uri() . '/js/app.js',  array('jquery', 'foundation_js' ), ' ', true );
    }
    add_action( 'wp_enqueue_scripts', 'wpt_theme_js');

?>

What am I missing? Please advise.

Do you mean it isn't showing the thumbnail option in the post editor or in the published post, or both?

@rvandaalen: Both.

Something just occurred to me. An obvious problem that may have bearing on this: I already have a portfolio page for my resume (http://local.wordpress.dev/portfolio). To that I've added a custom portfolio post type, as per the above instructions (http://local.wordpress.dev/portfolio/pink-triangle/). Does this fool WP into considering both to be items of the same type?

5 Answers

jsdevtom
jsdevtom
16,963 Points

WORKED FOR ME - This answer comes from Chiedo Labs in another question that asks the same thing:

"For any future watchers make sure: You go to CPT UI => edit post type => select 'portfolio' => scroll all the way to the bottom => check supports: Featured Images."

patrick kellogg
patrick kellogg
7,579 Points

thanks awesomedude - that fixed it for me too.

Peter Gregory
Peter Gregory
6,614 Points

Cool! Thank you

I was almost ready to delete all the 2 CPT plugins and start over! then I thought, I bet someone else already had this problem.

All fixed!

Creating the post types was a bit confusing because the two plugins have been updated since this tutorial was made and the interface looked a little bit different.

patrick kellogg
patrick kellogg
7,579 Points

i got the the featured image check box by CPT UI -> Supports -> Featured Image checkbox checked. i hope we are talking about the same problem. thanks. The latest CPT UI does not match the older screencast exactly.

Actually, now that you mention it, I think I went back & forth with CPT UI as well. I also checked, then unchecked & possible re-checked Featured image.

Did you use Custom post type UI or register_post_type()? in case of the first it should work, if the latter you need to make sure that you've got thumbnail support when you register the custom post type:

<?php
function custom_post_type() {
    $args = array(
      'support' => 'thumbnail',
      etc.....
    );
    register_post_type( 'custom_post_type_name', $args );
}
add_action( 'init', 'custom_post_type' );

?>

I'm using Custom Post Type UI.

Thanks.

patrick kellogg
patrick kellogg
7,579 Points

i am having the same problem. there is no option to set the featured image as depicted in the video with this code. adding as perrvandaalen's suggestion blows away rights to edit this custom content.

patrick kellogg
patrick kellogg
7,579 Points

blows away rights if using Custom Post Type UI only,

Right at the beginning of the chapter, Zac says, "However, there's a reason we don't want to do it this way: Once someone switches themes, all the code used to create the custom post type disappears & the content becomes unavailable." So forget about using register_post_type().

My setup was rather idiosyncratic--I'd created a portfolio page before starting the tutorial, then added a photography custom post type & another page. I don't remember specifically what I did to sort out the problem, but I think it had to do with editing the page urls & going back & forth, adding the graphics, deleting them & then adding them again. I'm afraid I don't have anything more helpful than that.

Memo to self for the future: document everything when solving problems.