Post Thumbnail on Custom Post Type


#1

Hello,

I need some help here on how to display post thumbnail at sidebar in custom post type. here’s my code

if ( function_exists( 'add_theme_support' ) ) { 
    add_theme_support( 'post-thumbnails', array( 'post', 'page', 'custom-post-type' ) );
}

seems not working… anyone could help me?

thanks :slight_smile:


#2

add_theme_support( ‘post-thumbnails’); is all you need.

I think the problem may lie elsewhere. Paste your custom post type code.


#3
add_action( 'init', 'gallery_post_type' );
	function gallery_post_type() {
		register_post_type( 'gallery',
			array(
				'labels' => array(
					'name' => __( 'Galleries' ),
					'singular_name' => __( 'Gallery' ),
					'add_new_item' => 'Add New Gallery',
					'edit_item' => 'Edit Gallery',
				),
				'public' => true,
				'has_archive' => true,				
				'rewrite' => array('slug' => 'gallery'),
				'supports' => array('title','editor','author')				
			)
		);
	}	
	
	/*META*/
	function gallery_meta() {
		global $post;
		$custom = get_post_custom($post->ID);
		$image = $custom["image"][0];			
		?>
			
Large Image (this is will be use for resizing)
<?php add_meta_box( $id, $title, $callback, $page, $context, $priority ); } /*TAXONOMIES*/ add_action( 'init', 'gallery_taxonomies', 0 ); function gallery_taxonomies() { register_taxonomy( 'gallery_categories', 'gallery', array( 'hierarchical' => true, 'label' => 'Categories', 'query_var' => true, 'rewrite' => true ) ); } /*CUSTOM COLUMNS*/ add_filter( 'manage_edit-gallery_columns', 'edit_gallery_columns' ) ; function edit_gallery_columns( $columns ) { $columns = array( 'cb' => '', 'title' => __( 'Title' ), 'category' => __( 'Categories' ), 'author' => __( 'Author' ), 'date' => __( 'Date' ) ); return $columns; } /*CUSTOM COLUMNS LIST*/ add_action( 'manage_gallery_posts_custom_column', 'manage_gallery_columns', 10, 2 ); function manage_gallery_columns( $column, $post_id ) { global $post; switch($column) { case 'category' : $terms = get_the_terms( $post_id, 'gallery_categories' ); if ( !empty( $terms ) ) { $out = array(); foreach ( $terms as $term ) { $out[] = sprintf( '%s', esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'gallery_categories' => $term->slug ), 'edit.php' ) ), esc_html( sanitize_term_field( 'name', $term->name, $term->term_id, 'gallery_categories', 'display' ) ) ); } echo join( ', ', $out ); } else { _e( 'No Categories' ); } break; default : break; } }

#4

thanks for the help @themeProvince… seems I got the solution … :slight_smile:

'supports' => array('title','editor','author','thumbnail')

#5
mabuc said

thanks for the help @themeProvince… seems I got the solution … :slight_smile:

'supports' => array('title','editor','author','thumbnail')

Exactly what I was going to suggest. Glad you got it sorted.