WordPress.org

Ready to get started?Download WordPress

Forums

Problem with the_post_image() in 2.9 beta 2 (3 posts)

  1. Arnold Goodway
    Member
    Posted 4 years ago #

    I am trying to show a thumbnail with a link to the actual post. The HTML I use is the following:

    <?php the_post_image() ; ?>

    In functions.php I have the following filter:

    add_filter( 'post_image_html', 'my_post_image_html', 10, 3 );
    
    function my_post_image_html( $html, $post_id, $post_image_id );
    
    	$html = '' . $html . '';
    
    	return $html;
    }

    This code for the filter I got from Justin Tadlock's site. This works with regards to the link but I get a double 'title' setting. The code I end up with is the following:

    <a href="http://nice2all.com/2009/12/07/yellow-rose/" title="Yellow Rose"><img width="150" height="150" src="http://nice2all.com/wp-content/uploads/2009/12/flower4-150x150.jpg" class="attachment-thumbnail wp-post-image" alt="" title="flower4" /></a>

    The second 'title' (the one I do not want) overwrites the first one. Any assistance would be appreciated.

  2. Arnold Goodway
    Member
    Posted 4 years ago #

    The code for the filter did not come out correctly here. The code I used is exactly the same as that provided by Justin Tadlock. Thanks.

  3. AlternativePhotography
    Member
    Posted 4 years ago #

    For getting the thumbnail i use:
    <?php the_post_thumbnail( 'thumbnail' ); ?>
    Does that work for you?

Topic Closed

This topic has been closed to new replies.

About this Topic