Looking to list post attachments made by Gravity Forms (or other plugins) inside the WordPress admin single? Here’s a guide on how to do it.
1 answers
1
Use a metabox to display post attachments
You should use a custom meta box and loop through your post’s attachments using the example below. You can also specify the post type accordingly, should you need this only for a custom post type.
function metabox_view_upload_files() {
add_meta_box( 'att_thumb_display', 'Files', function( $post ) {
$args = array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'post_parent' => $post->ID
);
echo '<ul>';
foreach( get_posts( $args ) as $image) {
echo '<li><a href="' . wp_get_attachment_url( $image->ID ) . '" target="_blank">' . wp_get_attachment_url( $image->ID ) . '</a></li>';
}
echo '</ul>';
}, 'post' ); // Change your post type here
}
add_action( 'add_meta_boxes', 'metabox_view_upload_files' );
— Support WizardAnswer 1