If you do `$content = "something";` you are replacing the `$content` variable's value. If you want to append something to the current content, you'd need to do something like: $content = 'initial content'; $content .= 'more content (notice the dot)'; In this case, if you want to append the image to some existing content you'd need to do: $content = get_the_content(); //or wherever the existing content is $content .= $link[$i].'<br><img src="'.$src.'" alt="'.$img_title.'" title="'.$img_title.'" class="alignnone size-full wp-image-'.$img_id.'" width="500"/>'; Or the reverse if you want to put the image first, before any content.