flaviowd
Member
Posted 1 year ago #
Hello everybody.
I´m uploading some pdf files and .doc/docx files in a project.
So, I´m inserting a link attachment file inside the loop and is working fine.
But I need to get a specific atribute: the mimetype.
So, I need to print the attachment url and mimetype, like this
Download file on http://domain.com/wp-content-....file.pdf
Fyle Tipe: pdf or application/pdf
Could someone helpme with this.
By the way, I´m using a custom theme and not the default wordpress theme.
Tks a lot
Flávio
flaviowd
Member
Posted 1 year ago #
Hello everybody,
I looked into media.php file at line 911, and I got success using this:
<li> Download File:
<?php $args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID );
$attachments = get_posts($args);
if ($attachments) {
foreach ( $attachments as $attachment ) {
the_attachment_link( $attachment->ID , false ); } } ?> </li>
<li>File Type: <?php echo $attachment->post_mime_type; ?></li>
I don´t know if this is the best solution, but anyway, this is working.
Tks a lot