Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

WordPress From Bootstrap to WordPress Create Bootstrap Styled Theme Templates Creating a Portfolio Landing Page

Featured images enabled on posts and pages, but not the custom post type

As far as I can tell I've done exactly what the video has asked, setting up the custom post type properly, and the custom field. And I've added the post-thumbnails command which enables me to add featured images to posts or pages, but not for the custom posts.

Can anyone help?

Can you paste in some code? It's hard to say what's wrong if there isn't any code on the reference.

OK.

Here's my functions.php

<?php

function theme_styles() {

  wp_enqueue_style( 'bootstrap_css', get_template_directory_uri() .  '/css/bootstrap.min.css' );
  wp_enqueue_style( 'main_css', get_template_directory_uri() .  '/style.css' );

}
add_action( 'wp_enqueue_scripts', 'theme_styles' );

function theme_js() {

  global $wp_scripts;

  wp_register_script( 'html5_shiv', 'https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js', '', '', false );
  wp_register_script( 'html5_shiv', 'https://oss.maxcdn.com/respond/1.4.2/respond.min.js', '', '', false );

  $wp_scripts->add_data( 'html5_shiv', 'conditional', 'lt IE 9' );
  $wp_scripts->add_data( 'respond_js', 'conditional', 'lt IE 9' );

  wp_enqueue_script( 'bootstrap_js', get_template_directory_uri() .  '/js/bootstrap.min.js', array('jquery'), '', true );

}

add_action( 'wp_enqueue_scripts', 'theme_js' );

//add_filter ( 'show_admin_bar', '__return_false' );

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

function register_theme_menus() {

  register_nav_menus(
    array(
      'header-menu'   => __( 'Header Menu' )
    )
  );
}
add_action( 'init', 'register_theme_menus' );

function create_widget( $name, $id, $description ) {

    register_sidebar(array(
        'name' => __( $name ),   
        'id' => $id, 
        'description' => __( $description ),
        'before_widget' => '<div class="widget">',
        'after_widget' => '</div>',
        'before_title' => '<h3>',
        'after_title' => '</h3>'
    ));

}

create_widget( 'Front Page Left', 'front-left', 'Displays on the left of the homepage' );
create_widget( 'Front Page Center', 'front-center', 'Displays on the center of the homepage' );
create_widget( 'Front Page Right', 'front-right', 'Displays on the right of the homepage' );

create_widget( 'Page Sidebar', 'page', 'Displays on the side of pages with a sidebar' );
create_widget( 'Blog Sidebar', 'blog', 'Displays on the side of pages in the blog section' );

?>

I don't think the issue is here though, as I've successfully added the featured image functionality to the site in general.

5 Answers

Hi NIck,

One thing to check would be the settings of your custom post type.

From the WP admin:

  • Hover over CPT UI in the left navigation.
  • Click on Add/Edit Post Types.
  • Select the post types having the issues.
  • On the right hand side there will be Labels and Settings. Click Settings to expand the menu.
  • Scroll down until you see Supports with a list of tick boxes.
  • Ensure Featured Image is ticked.
  • Save changes.

Hope that helps in some way :)

-Rich

Thanks Rich, that was indeed the problem.

Much appreciated!

No problem :)

Diego Palma
Diego Palma
12,653 Points

This solved my problem as well. Many thanks!

No problem :)

Thks!!!

Thks!!!

No problem :)

Had encountered the same problem. Rich's answer has saved the day. Thanks

No problem :)

-Rich

No problem :)

Michael Hazani
Michael Hazani
1,043 Points

solved my problem as well. This is really not a bug as much as a crucial part of the tutorial and should be included as such! First report is over a year ago - get your act together, Treehouse... And thanks, Rich!

No problem. Glad it helped! :)

Erica Burdett
Erica Burdett
2,468 Points

Just in case you're feeling unappreciated, Thanks!

Haha no problem! It's good to see its still helping after a year :D

Make that two years later!