WordPress.org

Ready to get started?Download WordPress

Forums

Insert image at arbitrary point in post automatically (4 posts)

  1. iamharlan
    Member
    Posted 5 years ago #

    Hey...

    My website is at http://www.theparadigmexchange.com

    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.
    Harlan.

  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 5 years ago #

    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.

  3. iamharlan
    Member
    Posted 5 years ago #

    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')); ?>
    
    </div>

    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....
    Harlan

  4. iamharlan
    Member
    Posted 5 years ago #

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

    .picleft {
    	float:left;
    	margin:3px 14px 10px 0;
    	border:7px solid #f2f2f2;
    	}
    
    .picright {
    	float:right;
    	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.

    Harlan

Topic Closed

This topic has been closed to new replies.

About this Topic