Site logo

Archived topic

Show only certain categories as full posts in search results

3 replies · Started by Former User on December 28, 2020

Viewing posts 1–4 of 4

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!

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 :)

Thank you Tom!

Worked like a charm with the 'Code Snippets' plugin.

Glad I could help :)

This archived topic is closed to new replies.