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 
- Exclusive Author
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Sold between 250 000 and 1 000 000 dollars
- Author was Featured
- Item was Featured
- Attended a Community Meetup
- Referred between 100 and 199 users
- Contributed a Tutorial to a Tuts+ Site
add_theme_support( ‘post-thumbnails’); is all you need.
I think the problem may lie elsewhere. Paste your custom post type code.
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];
?>
<div class="inside">
<div class="form-wrap">
<label><strong>Large Image <i>(this is will be use for resizing)</i></strong></label> <input name="image" type="text" value="<?php echo $image; ?>" style="margin-top:4px; width:95%;" />
</div>
</div>
<?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' => '<input type="checkbox" />',
'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( '<a href="%s">%s</a>',
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;
}
}

'supports' => array('title','editor','author','thumbnail')
- Exclusive Author
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Sold between 250 000 and 1 000 000 dollars
- Author was Featured
- Item was Featured
- Attended a Community Meetup
- Referred between 100 and 199 users
- Contributed a Tutorial to a Tuts+ Site
mabuc said
thanks for the help @themeProvince.. seems I got the solution …
'supports' => array('title','editor','author','thumbnail')
Exactly what I was going to suggest. Glad you got it sorted.
