Created
April 2, 2014 22:12
-
-
Save cesjam7/9944295 to your computer and use it in GitHub Desktop.
Traer archivos adjuntos de una página wordpress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Con esta función podremos traer los archivos adjuntos de una página. Solo ponemos este código en la página deseada y nos mostrará los archivos. */ | |
$args = array( | |
'post_type' => 'attachment', | |
'numberposts' => null, | |
'post_status' => null, | |
'post_parent' => $post->ID | |
); | |
$attachments = get_posts($args); | |
if ($attachments) { | |
foreach ($attachments as $attachment) { | |
/* Aquí nos lista los archivos adjuntos */ | |
echo apply_filters('the_title', $attachment->post_title); | |
/* Si deseas un enlace hacia ese archivo escribe este código. */ | |
the_attachment_link($attachment->ID, false); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment