Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter lag47

    (@lag47)

    For the record, I was able to get the featured image meta box to work when I created the new post type manually. So it’s not a wp issue

    There are constant changes to the core of WP 3.0, so it can happen that things get broken, and it’s likely that will happen until 3.0 is actually released. With the WP 3.0 nightly build from the day GD Custom Posts And Taxonomies Tools 1.1 was released, post thumbnails were working.

    In anycase, I will release new versions every few days to follow the development of WP. New plugin version will be released tomorrow.

    Make a plugin with the following:

    Make sure to change the “your custom post type name” in this with your own data.

    <?php
    /*
    Plugin Name: Thumbnails
    Plugin URI:
    Description: Custom plugin made for Latravia.com
    Author: Frits Garrer
    Version: 1.0
    Author URI:
    */
    
    if ( !function_exists('fb_AddThumbColumn') && function_exists('add_theme_support') ) {
    
    	// for post and page
    	add_theme_support('post-thumbnails', array( 'post', 'page', 'your custom post type name' ) );
    
    	function fb_AddThumbColumn($cols) {
    
    		$cols['thumbnail'] = __('Thumbnail');
    
    		return $cols;
    	}
    
    	function fb_AddThumbValue($column_name, $post_id) {
    
    			$width = (int) 35;
    			$height = (int) 35;
    
    			if ( 'thumbnail' == $column_name ) {
    				// thumbnail of WP 2.9
    				$thumbnail_id = get_post_meta( $post_id, '_thumbnail_id', true );
    				// image from gallery
    				$attachments = get_children( array('post_parent' => $post_id, 'post_type' => 'attachment', 'post_mime_type' => 'image') );
    				if ($thumbnail_id)
    					$thumb = wp_get_attachment_image( $thumbnail_id, array($width, $height), true );
    				elseif ($attachments) {
    					foreach ( $attachments as $attachment_id => $attachment ) {
    						$thumb = wp_get_attachment_image( $attachment_id, array($width, $height), true );
    					}
    				}
    					if ( isset($thumb) && $thumb ) {
    						echo $thumb;
    					} else {
    						echo __('None');
    					}
    			}
    	}
    
    	// for posts
    	add_filter( 'manage_posts_columns', 'fb_AddThumbColumn' );
    	add_action( 'manage_posts_custom_column', 'fb_AddThumbValue', 10, 2 );
    
    	// for pages
    	add_filter( 'manage_pages_columns', 'fb_AddThumbColumn' );
    	add_action( 'manage_pages_custom_column', 'fb_AddThumbValue', 10, 2 );
    }

    I thought that the GD Custom Posts And Taxonomies Tools plugin would add the thumbnail option automatically for my custom post type if I selected the appropriate option. However it didn’t so what I did is I simply edited the functions.php file for my theme and added the code:

    add_theme_support('post-thumbnails', array( 'post', 'mycustomposttype'));

    However for the sake of consistency I also left the option of Post Thumbnails selected for my custom post type in the plugin.

    Here is an excelent post about this feature.

    Cheers,
    P.

    I will add this with next version as an option.

    Milan

    Milan,

    If you do add this option, don’t forget the additional options for this function related on the article (see link of my previous post) such as thumb size, and other custom thumb types.

    Cheers,
    P.

    Hi Milan,

    Another suggestion for you: Why not allow the user to specify the icon used by the custom post type?

    Like, if I created a post type called hotels, I might want to put a nice little icon of a Hotel…

    Just a little idea… I can see in the WP 3.0 functions that it does support this feature… ??

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Plugin: GD Custom Posts And Taxonomies Tools] thumbnails (featured image) and custom post types’ is closed to new replies.