Hi,
I need help creating a page (image gallery) in wordpress that displays all images that were embedded in every post of my site. I searched google, this forum and even the wordpress forum, but didn’t find anything useful, so I hope someone can help me solve this.
So far I’m using this code that I found and made a few tweaks to work with my site.
$args = array( 'post_type' => 'attachment', 'post_mime_type' => 'image', 'numberposts' => -1, 'post_status' => 0 );
$i = 1;
$attachments = get_posts($args);
if ($attachments) {
foreach ( $attachments as $attachment ) { ?>
post_title ); ?>
ID , false ); ?>
}
}
?>
The only problem is that, this code is capturing all the image files that were uploaded to my site. In other words, any image file that is inside the media library.
If I try to use ‘post_type’ => ‘post’ and/or ‘post_status’ => ‘publish’ it doesn’t show anything.
I know I must be doing something wrong, but since I’m no php expert I don’t know what I’m missing.
Can someone help me?