According to WP codex the code copied below will return a list of images attached to a "page". I have yet see this happen and I'm at a complete loss as to why:
I have created a template page called gallery-test and within it I have pasted the code as in the example listed in the WP codex,
...I have set my page to the gallery-test template page. I have attached 5 images with titles to the page,
... the result is an empty page.
Any suggestions or help would be most appreciated!
<ul>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post();
$args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_parent' => $post->ID
);
$attachments = get_posts( $args );
if ( $attachments ) {
foreach ( $attachments as $attachment ) {
echo '<li>';
echo wp_get_attachment_image( $attachment->ID, 'full' );
echo '<p>';
echo apply_filters( 'the_title', $attachment->post_title );
echo '</p></li>';
}
}
endwhile; endif; ?>
</ul>