Hello stackoverflow friends!
Hopefully somebody here can help me with this! I’ve looked all over the internet with no luck 🙁
What I want to do is somehow show the images attached to a post inside the WP admin. For example, the same way the post Featured Image shows. The only thing I found was how to display the number of attachments of a post in the admin columns but what I would like to see is thumbnails of all attached images inside each post in the post admin page. I think this will be very helpful since right now I cannot even tell which post has attachements.
I will like to accomplish this without using a plugin.
I have looked for days online with no luck. Any help will be greatly appreciated.
Thank you very much in advanced!
The solution is to create a meta box and then put the thumbnails in there. This requires the add_meta_box() function and wp_get_thumb_attachment_url(). We also need to find all attached images of a certain post, which we’ll do using the answer here.
Putting all this together, and assuming PHP version >= 5.3 so that we can use anonymous functions, it will look like this:
The argument of
add_meta_box
that I’ve set to “post” indicates on which post type this meta box will be available. If you want it available on pages, you have to set it to pages. Or if you want it to be available on a custom post type, you will also have to modify it accordingly.I hope this works. I haven’t tried it.
try this :
it will show you the featured image as preview in the manage post /page list ,
If you want to show it inside the post itself – use @Calle suggestion:
(modified here to work)