0

I have this code in my functions.php file to display the excerpt of every post right below the content of every post.

But, for some reason the Excerpt is appearing above the Content when it should be below it.

Can someone show me how to make sure that the Excerpt always show up under the Content...? Thanks.

function after_post_content($content){
if (is_single()) {  
    $content .= the_excerpt();
}
    return $content;
}
add_filter( "the_content", "after_post_content"); 
2

You are echoing the content of the excerpt, which is being put into the header. Use get_the_excerpt() instead:

function after_post_content($content){
if (is_single()) {  
    $content .= get_the_excerpt();
}
    return $content;
}
add_filter( "the_content", "after_post_content");

Generally, WordPress functions beginning with the_ will echo the output, while functions starting will get_the_... will get the value.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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