We're using a theme for a client that has programmed in their own excerpt & it's alright but it doesn't separate the title from the text in the excerpt itself, which is shown on the blog page. Here's the code:

function tt_excerpt( $id, $length = NULL ) {
    $length = !empty($length) ? $length : 55;
    $content = apply_filters( 'the_content', get_post_field('post_content', $id));
    $content = strip_shortcodes($content);
    $content = str_replace(']]>', ']]>', $content);
    $content = strip_tags($content);
    $content = substr($content, 0, $length);
    return $content.'...';

My PHP isn't nearly as strong as my CSS so I'm not entirely certain how to define the title in this excerpt code. I appreciate any insight!

  • With this theme, replacing the call for the custom excerpt with the_excerpt doesn't seem to do it.
    – Jeff W
    Commented Dec 18, 2016 at 17:01

1 Answer 1


The title isn't mentioned anywhere in that code, have they included it in the actual content?

If so, you could remove it using a str_replace:

$content = str_replace( get_the_title($id), '', $content);
  • Cheers, TCode! This, in conjunction with the_title in the right place was what was called for.
    – Jeff W
    Commented Dec 20, 2016 at 16:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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