Support » Fixing WordPress » newlines before and after excerpt

  • I’m displaying my excerpt on my website using <?php the_excerpt(); ?>
    I’m getting a space above and below the excerpt — it’s like WP is inserting a couple line breaks above and below the excerpt. How can I remove these breaks? They’re not in the html.
    BTW, the excerpt is imported from MT. I don’t know if the import process somehow caused these newlines to appear. My guess is no, because when I go to the edit screen in wp-admin, I don’t see any extra spaces in the excerpt field.

Viewing 5 replies - 1 through 5 (of 5 total)
  • It should be stylable from the CSS.
    Is there a specific post you can indicate that has this issue ?

    Thread Starter emsdc

    (@emsdc)

    I just viewed the source code on my page and it looks like WP is putting paragraph tags around my excerpt, even though they’re not in index.php.
    See http://www.ems.org/wordpress/index.php?p=4
    “Cancer Prevention Coalition” is the excerpt. I’m using the excerpt field to specify a “source” for each post, since the source is sometimes different than the author on my site.
    This doesn’t look to be a CSS issue to me. It looks like the CMS has something built into it that assumes an excerpt is its own paragraph.

    .storycontent p {
    margin: 2px 0 2px 0;
    }
    That will reduce the top and bottom margins to 2px, but you cal alter those around obviously.

    Thread Starter emsdc

    (@emsdc)

    This still creates an unwanted line break. Paragraph tags create a line break, even if the margins are set to zero.

    Thread Starter emsdc

    (@emsdc)

    I figured this out… I just needed to comment out this line…
    add_filter(‘the_excerpt’, ‘wpautop’);
    …in template-functions-post.php

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘newlines before and after excerpt’ is closed to new replies.