Hi,
I'm trying to set up a page that shows all my post with image in different categories.
I searched for any relevant post but all I can find is "List all images attached to a post".
I tried using get_post function but it only displays all image.
<?php
$args = array( 'post_type' => 'attachment', 'posts_per_page' => -1, 'post_status' => 'any', 'post_parent' => null );
$attachments = get_posts( $args );
if ( $attachments ) {
foreach ( $attachments as $post ) {
setup_postdata( $post );
the_title();
the_attachment_link( $post->ID, false );
the_excerpt();
}
wp_reset_postdata();
}
?>
Can someone help me out? Thanks!