WordPress.org

Forums

[resolved] Manual Excerpts or Full Content ONLY? (2 posts)

  1. SpankMarvin
    Member
    Posted 4 years ago #

    Hi all

    I thought this would be a relatively simple thing to achieve, but guess I'm missing something.

    I am setting up a blog in which, for listings, I want a manual excerpt to appear. No issues there, except that at the moment, if there is no excerpt put in, WordPress makes one automatically out of the content. I have the following code in the loop:

    <?php $blog_ex = get_the_excerpt();
    if( $blog_ex != '' ){
    	the_excerpt();
    } else {
    	the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) );
    } ?>

    My guess is that get_the_excerpt is already returning something automatically so that my variable is never == ''... so would filtering be the way to go?

    Any advice much appreciated

    John

  2. SpankMarvin
    Member
    Posted 4 years ago #

    I figured this out! Instead of using the get_the_excerpt function, I used the post object to gauge whether a manual excerpt was added.

    $blog_ex = get_the_excerpt();

    becomes

    $blog_ex = $post->post_excerpt;

    and it now functions as required.

    J

Topic Closed

This topic has been closed to new replies.

About this Topic