WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

By default, the_excerpt() displays the content before the <!--more-->, trimming it at ~50 words.

Is there any way to prevent this trimming functionality when the <!--more--> is present, but still have it work when <!--more--> is absent?

Thanks!

share|improve this question

Here's the hacky way I figured it out:

if ( preg_match( '/<!--more-->/', $post->post_content ) ) {
    $content = apply_filters( 'the_content', get_the_content( '' ) );
    echo ( $content );
} else {
    the_excerpt();
}

(Note that I have a separate "Read More" link after this snippet; if you're wanting to use The Content's default Read More link, remove the space from get_the_content();.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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