1

I use excerpts of posts in my front page. In my excerpt, the summary of the post seems to be clumped together with no spaces that are indicated in the post (e.g., paragraph spaces are automatically removed). I understand this is the default behavior.

Question: Is there a way to retain the paragraph in excerpts?

To show excerpt on the fron page in my Twenty Ten theme's loop.php I changed this (around line #137:

<?php if ( is_archive() || is_search() ) : // Only display excerpts for archives and search. ?>

with this:

<?php if ( is_home() || is_front_page() || is_archive() || is_search() ) : // Only display excerpts for archives and search. ?>

thanks.

1

Looks like my other answer wasn't working, so I looked into it and found this:

http://aaronrussell.co.uk/legacy/improving-wordpress-the_excerpt/

That article should give you all you need to keep the <p> tags in there.

0

The line that's important isn't likely to be the "if", it's this one:

<?php the_excerpt(); ?>

That's what spits out the content. Adding nl2br (http://php.net/manual/en/function.nl2br.php) should help return the linebreaks.

You'll have to manually echo it out, though, so you should use "get_the_excerpt()" instead.

This line should work:

<?php echo nl2br(get_the_excerpt()); ?>
  • thanks Samuel for reply. I tried replaing <?php the_excerpt(); ?> with <?php echo nl2br(get_the_excerpt()); ?>, but it did not change anything – Tara Jul 17 '11 at 4:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.