Skip to content

Instantly share code, notes, and snippets.

@leobaiano
Created April 19, 2016 16:41
Show Gist options
  • Save leobaiano/230e40724232c558bf0ba0b379770e23 to your computer and use it in GitHub Desktop.
Save leobaiano/230e40724232c558bf0ba0b379770e23 to your computer and use it in GitHub Desktop.
WordPress - Código para pegar todas as imagens anexadas em um post
<?php
$args = array(
'post_parent' => $post->ID,
'post_type' => 'attachment',
'numberposts' => -1, // show all
'post_status' => 'any',
'post_mime_type' => 'image',
'orderby' => 'menu_order',
'order' => 'ASC'
);
foreach ( $images as $image )
echo wp_get_attachment_url( $image->ID );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment