• My template doesn’t include support for adding excerpts on its own. I’ve added the excerpt to the child theme. The other issue is that the theme automatically adds the post’s featured image above the text, and it appears inline with the excerpt (rather than below it).

    This is the code I added to show the excerpt:

    <span class="post-byline"><?php if($post->post_excerpt) the_excerpt(); ?></span>

    The theme then posts the image like this:

    <?php the_post_thumbnail('post-thumb'); ?>

    I have tried adding breaks twice after the excerpt line, but this also produces ugly gaps on posts where there is no excerpt. How can I insert the line breaks only when there is an excerpt present?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi @passa,

    I have tried adding breaks twice after the excerpt line, but this also produces ugly gaps on posts where there is no excerpt. How can I insert the line breaks only when there is an excerpt present?

    You can change your above excerpt code as following to achieve this.

    Before Editing:

    <span class="post-byline"><?php if($post->post_excerpt) the_excerpt(); ?></span>

    After Editing:

    <span class="post-byline">
       <?php if($post->post_excerpt){
           the_excerpt();
           echo '<br /><br />';
        } ?>
    </span>

    Best Regards,

    Thread Starter Passa

    (@passa)

    EDIT: Nevermind, changed it to a heading type and the problem has gone away. Thank you for your help!

    Hi @passa,

    Try using the following code.

    <?php if($post->post_excerpt){
           echo '<span class="post-byline">';
           the_excerpt();
           echo '</span><br /><br />';
        } ?>

    Also share me the page link if you need any further assistance, this might help get to the bottom of this faster.

    Kind Regards,

    Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    What do you mean ‘heading type’?

    ps. if possible try to avoid using $post->the_except I would recommend using: has_excerpt() to check if it does exist. 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Adding excerpt to post page, but with space for featured image’ is closed to new replies.