Forums

How do I put Default Post Image Inside The_Content? (2 posts)

  1. ispreview
    Member
    Posted 1 year ago #

    Simple question with a difficult answer, assuming there is one.

    On my single.php I have this for my posts output.

    <?php the_post_thumbnail( array(350, 250) ); ?><?php the_content(); ?>

    The problem here is that when the code renders you get the IMG line right in front of the first P tag for the_content. For example..

    <img src="" /><p>text output for the_content..</p>

    Now what I'd like is for the 'Default Image' to be shown just inside the first P tag like this.

    <p><img src="" />text output for the_content..</p>

    Anybody have any ideas about how to do that?

  2. threestyler
    Member
    Posted 1 year ago #

    You could add this before the loop:

    <?php remove_filter( 'the_content', 'wpautop' ); ?>

    More information on removing filters in the codex:
    Codex: Removing Filters

    And then manually add the p tags in the loop around your image and content call.

    This would also achieve the same thing but the above method is the better way to do it.

    <p>
    <?php the_post_thumbnail( array(350, 250) ); ?>
    <?php echo $post->post_content; ?>
    </p>

Topic Closed

This topic has been closed to new replies.

About this Topic