Forums

the_excerpt() (2 posts)

  1. unknownserv
    Member
    Posted 3 years ago #

    Is there anyway to beable to echo the_excerpt()? eg. instead of just putting the_excerpt() in the code, i'd put echo the_excerpt().

    Thanks

  2. geoffe
    Member
    Posted 3 years ago #

    Of course there is. It's get_the_excerpt()

    All the template tags use some such method to take care of the 'echoing' for you.

    See here from template-functions-post.php:
    function the_excerpt() {
    echo apply_filters('the_excerpt', get_the_excerpt());
    }

    function get_the_excerpt($fakeit = true) {
    global $id, $post;
    $output = '';
    $output = $post->post_excerpt;
    if ( !empty($post->post_password) ) { // if there's a password
    if ( $_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password ) { // and it doesn't match the cookie
    $output = __('There is no excerpt because this is a protected post.');
    return $output;
    }
    }

    return apply_filters('get_the_excerpt', $output);
    }

Topic Closed

This topic has been closed to new replies.

About this Topic