Displaying uploaded attachments

We need a way to display the uploaded files within the post edit screen as well as on the frontend, after the post content. For this, we are going to use a common function called wpqpa_file_attachment_list to generate an attachments list, as shown in the following code:

function wpqpa_file_attachment_list( $post ){  global $wpdb;  $display = '<div class="wpqpa-files-list" >';  $sql = $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}wpqpa_post_attachments WHERE post_id = %d order by updated_at desc ", $post->ID );  $files_list = $wpdb->get_results( $sql );  foreach( $files_list as $file_row ){    $url = get_permalink( $file_row->post_id ); $url = wpqpa_add_query_string( $url, "wpqpa_file_download=yes&wpqpa_private_file_id ...

Get WordPress Development Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.