Skip to main content
improved formatting, replaced `the_content` with `get_the_content`
Source Link
tfrommen
  • 9.2k
  • 7
  • 39
  • 59

If you do $content="something";$content = "something"; you are replacing the $content$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=the_content$content = get_the_content(); //or wherever the existing content is
$content.=$link[$i] .'<br>'= $link[$i].'<img'<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.

If you do $content="something"; you are replacing the $content value. If you want to append something to the 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=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.

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.

Source Link
guidod
  • 741
  • 5
  • 11

If you do $content="something"; you are replacing the $content value. If you want to append something to the 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=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.