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

Home Forums Support [Resolved] Display full excerpt of CPT's in archive/search results (no "read more")

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

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #967101
    Morgan

    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.

    #967510
    Tom
    Lead Developer
    Lead Developer

    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 πŸ™‚

    #969613
    Morgan

    Yep, nailed it! πŸ™‚

    #969661
    Tom
    Lead Developer
    Lead Developer

    Awesome πŸ™‚

    #969670
    Morgan

    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.

    #970255
    Tom
    Lead Developer
    Lead Developer

    You could:

    1. Create a Hook Element: https://docs.generatepress.com/article/hooks-element-overview/
    2. Set the hook to after_content
    3. Add your content into the Hook content area.
    4. Set your Display Rules so your hook displays on single FAQ entries.

    #970878
    Morgan

    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!

    #971210
    Tom
    Lead Developer
    Lead Developer

    No problem! πŸ™‚

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.