WordPress.org

Ready to get started?Download WordPress

Forums

multiple excerpt lengths without stripping p tags? (4 posts)

  1. flint_and_tinder
    Member
    Posted 2 years ago #

    I've been using the following code to manually control the excerpt length. However when calling the excerpt using <?php echo excerpt(75); ?> any line breaks in the original excerpt get stripped out. Is there a way I can fix it so they are retained?

    [Code moderated as per the Forum Rules. Please use the pastebin]

  2. Calling the excerpt strips out all formatting totally, not just the paragraph tag.

    If you use the custom excerpt box, it'll keep all your HTML intact.

  3. flint_and_tinder
    Member
    Posted 2 years ago #

    I don't want to use the custom excerpt box though. I would like it to grab the content. Can I change something in here to bring the tags back in?

    $excerpt = preg_replace('\[[^\]]*\]','',$excerpt);

  4. johnfotios
    Member
    Posted 2 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic