I'm building a theme that display image according to a category. Exemple, There a Fashion section, which is a page. On that page I have uploaded photo related to fashion. Another page is Portraits, which display portrait photography and so on. On my home page I would like to display all the recent photo that I have uploaded through the other section/page.
Right now I can only show image related to a specific page or post with this script:
<?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; ?>
How can I extend this script to fetch images/photos in other post/page?
I would like to specified that I'm kind of new in theme developement...
Thanks in advance for your help.