[Resolved] Show only certain categories as full posts in search results

Home Forums Support [Resolved] Show only certain categories as full posts in search results

Home Forums Support Show only certain categories as full posts in search results

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1596387
    Anonymous

    I have trouble setting things up so that only my “…/category/blog/” posts are shown as full posts in my search results.

    I have tried to modify and add Tom’s “content-search.php” so that only the “…/category/blog/” is displayed as a full post in my search results.
    Unfortunately the podcast and video categories are also displayed as a full blog posts.

    Tom’s “content-search.php”:
    https://gist.github.com/generatepress/a12b5d716938324ed1a1

    Thanks!

    #1597297
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    You could try something like this:

    add_filter( 'generate_show_excerpt', function( $show ) {
        if ( is_search() && has_category( 'Blog' ) ) {
            $show = false;
        }
    
        return $show;
    } );

    This assumes the category is named “Blog”.

    Let us know ๐Ÿ™‚

    #1597314
    Anonymous

    Thank you Tom!

    Worked like a charm with the ‘Code Snippets’ plugin.

    #1598621
    Tom
    Lead Developer
    Lead Developer

    Glad I could help ๐Ÿ™‚

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