Site logo

Archived topic

Display full excerpt of CPT's in archive/search results (no "read more")

7 replies · Started by Morgan on July 25, 2019

Viewing posts 1–8 of 8

I searched and found a lot of related stuff, but a lot was years old, also need some guidance, and am hoping my need is simpler than most other solutions I saw!

I want to show the full text of my FAQ CPT's in archive and search results, without the read-more-button (mine's labeled "read"). All my CPT FAQ's are short so wont break layout. At the moment the only ones needing a button are over the 32 word count (which I want to keep for other post types) by about a sentence.

Hi there,

Try this:

add_filter( 'generate_show_excerpt', function( $show ) {
    if ( is_post_type_archive( 'your_faq_post_type_name' ) || ( is_search() && 'your_faq_post_type_name' === get_post_type() ) ) {
        return false;
    }

    return $show;
} );

Let me know :)

Yep, nailed it! :)

Awesome :)

Forgot something!

Would this be the best place to ask/is-it-possible to add a link at bottom of all helpie_faq content with this same filter, or somesuch?

Would be the same link on all FAQ pages sinply linking back to the FAQ dashboard.

Oh wow, that's so simple and powerful - I'm starting to get it by jove!

For any dropping by - it first appeared below where I'd placed the "share" buttons from https://wordpress.org/plugins/gp-social-share-svg/ on same hook, so I changed the priority of the Element to 1, and now it loads above Share buttons. Huzzah!

Seeing more in drop-down than at: https://docs.generatepress.com/article/hooks-visual-guide/ , does it need an update?

Thanks again and this officially resolved!

No problem! :)

This archived topic is closed to new replies.