• I have to add code to the WordPress-loop, because I want to display multiple images when visitors submit posts with the ‘User Submitted Posts’ plugin. I am using the SUVTown-Theme. To which file should I add this code and where?

    1
    2
    3
    4
    5
    6
    7
    8
    <?php // USP display linked images
    $args = array('order' => 'ASC','post_type'=>'attachment','post_parent'=>$post->ID,'post_mime_type'=>'image','post_status'=>null,'numberposts'=>-1,);
    $attachments = get_posts($args);
    if ($attachments) {
    	foreach ($attachments as $attachment) {
    		echo '<a rel="lightbox[gallery]">ID).'" title="'.get_the_title().'">'.wp_get_attachment_image($attachment->ID,'medium',false).'</a>';
    	}
    } ?>

    I have already tried to add it to the Index.php file, but it didn’t work. Does someone have a solution?

The topic ‘Add code to the Loop to display multiple images’ is closed to new replies.