Forums

Images and Excerpt (8 posts)

  1. natecross
    Member
    Posted 2 years ago #

    Thank you in advance for helping me with this issue. My question is about adding images to my Excerpts. I understand that to add an image I need to use the custom fields.
    I can't seem to find the right answer about editing my index page so that the image I insert into the custom fields section displays next to the excerpt of my post on my home page. I have read a couple different explanations on how to accomplish this and I haven't been successful yet. Any help would be great. I would like my images to display on the left side of my Excerpt. I understand how to add them to the custom fields, but don't know how to change the code so they display like I want them to.

    Here is a link to my site.

  2. Samuel B
    moderator
    Posted 2 years ago #

  3. doc4
    Member
    Posted 2 years ago #

    natecross,

    Try this: create a custom field and add a link to your image within it. Next put the following code into your theme.

    <img src="<?php echo get_post_meta($post->ID, 'myCustomFieldName', $single=true) ?>" border="0" taget="blank"> <?php the_excerpt(); ?>

  4. Shane G
    Member
    Posted 2 years ago #

    Hi,

    Have a check with this plugin:

    http://wordpress.org/extend/plugins/image-link/

    Thanks,

    Shane G.

  5. natecross
    Member
    Posted 2 years ago #

    Doc4 where go I insert that code?

  6. doc4
    Member
    Posted 2 years ago #

    natecross,

    This code includes the excerpt coding so you will just need to replace the excerpt code you currently have.

    If there is no excerpt code currently put this new code within the WordPress loop where you would like it to appear.

    For example:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
     <img src="<?php echo get_post_meta($post->ID, 'myCustomFieldName', $single=true) ?>" border="0" taget="blank">
     <?php the_excerpt(); ?>
    
    <?php endwhile; endif; ?>
  7. natecross
    Member
    Posted 2 years ago #

    Doc 4 this is the code for my index.php I am not sure where to put the code you supplied, Thank you for your help I am still learning.

    <?php get_header(); ?>
    		<?php if (have_posts()) : ?>
    		<?php while (have_posts()) : the_post(); ?>
    		<div class="post" id="post-<?php the_ID(); ?>">
    			<div class="post-header">
            <div class="date"> <?php the_time('M j') ?> <span><?php the_time('y') ?></span></div>
    				<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
            <div class="author">by <?php the_author() ?></div>
          </div><!--end post header-->
    			<div class="entry clear">
    				<?php the_excerpt(); ?>
            <?php edit_post_link('Edit This','<p>','</p>'); ?>
    			</div><!--end entry-->
          <div class="post-footer">
            <div class="comments"><?php comments_popup_link('Leave a comment', '1 Comment', '% Comments'); ?></div>
          </div><!--end post footer-->
    		</div><!--end post-->
    		<?php endwhile; /* rewind or continue if all posts have been fetched */ ?>
    		<div class="navigation index">
    			<div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
    			<div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
    		</div><!--end navigation-->
    		<?php else : ?>
    		<?php endif; ?>
    	</div><!--end content-->
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
  8. adminsip
    Member
    Posted 2 years ago #

    natecross,

    Did you ever figure this out? I'd like to do it to.

Topic Closed

This topic has been closed to new replies.

About this Topic