1179 posts
  • Has referred 200+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+2 more
mabuc says

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 :)

2587 posts Put a Donk On It
  • Elite Author: Sold more than $75,000 on Envato Market
  • Sells items exclusively on Envato Market
  • Made it to the Authors' Hall of Fame
  • Has sold $250,000+ on Envato Market
+10 more
ThemeProvince says

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

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

1179 posts
  • Has referred 200+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+2 more
mabuc says
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;
        }
    }
1179 posts
  • Has referred 200+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+2 more
mabuc says
thanks for the help @themeProvince.. seems I got the solution … :)
'supports' => array('title','editor','author','thumbnail')
2587 posts Put a Donk On It
  • Elite Author: Sold more than $75,000 on Envato Market
  • Sells items exclusively on Envato Market
  • Made it to the Authors' Hall of Fame
  • Has sold $250,000+ on Envato Market
+10 more
ThemeProvince says

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.

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by