I created a custom post type for Products. I can display all the fields no problem (either in a list or a single-product.php). I wanted to use the Media library and associate an uploaded picture with the Product post type (mostly to handle all the thumbnail work automatically). I uploaded a photo to the media library and associated with a specific Product post type.
$args = array(
'label' => __('Products'),
'labels' => $labels,
'public' => true,
'can_export' => true,
'show_ui' => true,
'_builtin' => false,
'capability_type' => 'post',
'menu_icon' => get_bloginfo('template_url').'/functions/images/product.png',
'hierarchical' => false,
'rewrite' => array( "slug" => "product" ),
'supports' => array('title', 'thumbnail'), //MAYBE add thumbnail later!
'show_in_nav_menus' => true
);
I've tried everything to display the thumbnail and picture for the Product but it's not working: the_post_thumbnail();
, get_the_post_thumbnail
but nothing works. Here's my single-product.php:
<div class="post_content">
<img class="thumb" src="<?php echo the_post_thumbnail(); ?>" alt="<?php the_title(); ?>" />
<p><?php echo get_post_meta($post->ID, $prefix.'description', true); ?></p>
<ul>
<?php //this gets the custom fields for the document links (PDF Files)
$custom_field_keys = get_post_custom_keys();
foreach ( $custom_field_keys as $key => $value ) {
$valuet = trim($value);
if ( '_' == $valuet{0} || $prefix != substr($valuet, 0, 4) || $prefix.'description' == $valuet )
continue;
$n = substr($valuet, -1);
if ( $valuet == $prefix.'docname'.$n)
echo '<li><a href="' . get_post_meta($post->ID, $prefix.'docurl'.$n, true) . '" target="_blank">' . get_post_meta($post->ID, $prefix.'docname'.$n, true) . '</a></li>';
}
?>
</ul>
</div><!-- end post_content -->
Am I missing something? Thank you!