Support » Fixing WordPress » attached images outside loop?

Viewing 1 replies (of 1 total)
  • Thread Starter markoburns

    (@markoburns)

    hi – I’ve found this code that works, but how do I not show the images that appear in the post loop?
    also if images are removed they still appear in the script, unless deleted from the media library – is there any way to fix this?

    <?php
    $args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_mime_type' => 'image' ,'post_status' => null, 'post_parent' => $post->ID );
    $attachments = get_posts($args);
    if ($attachments) {
    	foreach ( $attachments as $attachment ) { ?>
        <img src="<?php echo wp_get_attachment_url( $attachment->ID , false );  ?>" width="230" height="140" border="1" /></a>
    
    <?php	}
    }
    ?>
Viewing 1 replies (of 1 total)
  • The topic ‘attached images outside loop?’ is closed to new replies.