Support » Themes and Templates » Insert image at arbitrary point in post automatically

  • Hey…

    My website is at

    I searched for something like this, but wasn’t able to find one exactly like I want. If you know of one…any redirection would be great.

    I am wanting to use my existing image tags to insert an image into all posts. For now, I will probably pick and size each image to specifications, but eventually, I would like to be able to add an advertising image feed into it. An example of someone doing this is here. On my pages, it simply does the code for inserting post, so I’m unsure how to add an image into it at either exactly halfway through the post, or after one paragraph or so.

    Any ideas? Also, I’m working with relatively little CSS or PHP knowledge, so I’m having to do trial and error. So just telling me to add it to the loop won’t help me much…mostly because I don’t really know what that means. But I’m not a web idiot either…I can figure it out if someone can guide me through it.

    Thanks for any help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator Samuel Wood (Otto)

    (@otto42) Admin

    If you want to insert it INSIDE a post, then you’ll need to create a filter.

    Add a filter to ‘the_content’ and have it modify the content of the post to insert your image code.

    You’ll put your code into the theme’s functions.php file, most likely. Or create your own plugin to do it.

    Ok…let me back up a second. And if this post makes me sound incredibly dumb….I apologize.

    This is where my post is placed into my pages.

    <div class="entry">
    <?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
    <?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>

    Can I include the code that calls for a specific image tag somewhere in there? The code below is from my homepage; it calls the image up that has the key “blurb” from the custom fields section of the individual post.

    <?php $values = get_post_custom_values("Blurb");
    	if (isset($values[0])) {
          <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><img src="<?php bloginfo('template_url'); ?>/images/<?php $values = get_post_custom_values("Blurb"); echo $values[0]; ?>" alt="" /></a>
          <?php } ?>
          <a href="<?php the_permalink() ?>" rel="bookmark" class="title">

    Is it possible to somehow combine this code with the previous one, in order to have an image left aligned at the beginning of the content section of individual posts? Or even better, to have it show up about halfway in to the post, still left aligned?

    I looked at the filters section, and it may be over my head right now. If that’s the best way, I can give it a shot.

    Thanks again….

    Also….while I was looking through the CSS for the theme…I noticed that there are classes under “post formatting” for .picleft and .picright… they are.

    .picleft {
    	margin:3px 14px 10px 0;
    	border:7px solid #f2f2f2;
    .picright {
    	margin:3px 0 10px 14px;
    	border:7px solid #f2f2f2;

    I’m not sure where I am utilizing these tags on the site right now. It seems as though if it is built in, I might be able to use it somehow…..but I’m unsure.


Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Insert image at arbitrary point in post automatically’ is closed to new replies.