Site logo

Archived topic

How to remove Excerpt in single posts?

11 replies · Started by Jorge on June 21, 2018

Viewing posts 1–12 of 12

I dont want to display the summary/excert in single posts, only display the excert text in category views.

Could you help me with it?

Thanks a lot in advance!

Jorge

Hi Jorge,

to remove the excerpt on the blog page, but not on the category / archives you can use a filter like so:

add_filter( 'excerpt_length','lh_custom_category_excerpt_length', 1000 );
function lh_custom_category_excerpt_length( $length ) 
{
    if ( is_front_page() && is_home() ) {
        return 0;
    } 
    return $length;
}

https://docs.generatepress.com/article/adding-php/

Hello David, thanks for your fast answer.

I installed Code Snippets plugin and copy/paste your lines but it did not work...also I tried to copy your code to content-single.php but it did not work...

Some help please :-)

Jorge

Hi Jorge, sorry my mistake, the code above removes the excerpt from the main blog page not the single post.

How are you adding the excerpt? Or is the automatic excerpt?

Hi Jorge, don't use the code i provided as this will not remove the Excerpt from the Single Post (it works on the Blog Page).

You can add a manual Excerpt to a Post. In the Post Editor > Screen Options > check Excerpt.
This will display a Excerpt field in the post editor. This Excerpt will only show on the blog / archives / categories not in the single post.

Hi Jorge, you cannot apply the Read More and the Excerpt.
If you only have the Excerpt field completed then this should work.

Thanks a lot guys, it works now!

Glad we could help!

This archived topic is closed to new replies.