Skip to content

Instantly share code, notes, and snippets.

@cesjam7
Created April 2, 2014 22:12
Show Gist options
  • Save cesjam7/9944295 to your computer and use it in GitHub Desktop.
Save cesjam7/9944295 to your computer and use it in GitHub Desktop.
Traer archivos adjuntos de una página wordpress
<?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