I have a Custom Post Type and I am going to customize it to show a list of some products with images. I have all text fields working fine but I need also an image to be attached to each item. How can I do this?
Leave a Reply
You must be logged in to post a comment.
If each post is a single item, you can add post thumbnail support in your theme, which allows users to either browse for or upload an image and assign it to the post.
add_theme_support('post-thumbnails')
You’ll also need to add
thumbnail
to yoursupports
array when you register your custom post type.You can then retrieve the thumbnail in your theme files using
get_post_thumbnail()
. Check out the other post thumbnail functions inwp-includes/post-thumbnail-template.php
.