Site logo

Archived topic

post excerpt error in homepage

12 replies · Started by James on August 15, 2019

Viewing posts 1–13 of 13

Hello,

Only one post displays the whole post text on homepage. Other posts display titles without excerpts (I have set the excerpts length to zero).

I want to display titles only. What's the problem of the only post? Please help me.

Thanks very much!

Hi there,

seen this a couple of times before - for no explainable reason WP outputs the content.
What happens if you create a new post does that one display correctly?

Please I'm facing the same problem... I think it happens when you changed the post format from standard to any other format.
In my old theme, if I wanted to publish music I select format as music, video i select format as video...
Going through all my published post contents... All those posts showed the whole text content.

Except those ones published in standard format... Even in search or tag pages they display the whole post contents

Hi there,

Try this PHP snippet:

add_filter( 'generate_show_excerpt', function( $show ) {
    if ( 'audio' === get_post_format() ) {
        $show = true;
    }

    return $show;
} );

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

Let me know if this helps :)

Thanks it works

No problem :)

I just detected this morning that same error occurred for videos as well... And what if i have other post format like Quote and others that I've used in my previous theme? How do we deal with that?

Hi there,

so this part of the code checks to see if its an audio post:

if ( 'audio' === get_post_format() )

We can extend that to check for multiple post formats eg.

if ( 'audio' === get_post_format() || 'video' === get_post_format() || 'quote' === get_post_format() )

I'm getting php error after inserting this new code

the code should look like this:

add_filter( 'generate_show_excerpt', function( $show ) {
    if ( 'audio' === get_post_format() || 'video' === get_post_format() || 'quote' === get_post_format() ) {
        $show = true;
    }

    return $show;
} );

It did work for now... If I notice any error in any other format... Will get back to you

This archived topic is closed to new replies.