Site logo

Archived topic

How to style the search results page to match other archive layouts?

3 replies · Started by Sasha on October 14, 2022

Viewing posts 1–4 of 4

Hi there,

My search results page uses the same content template as my archive pages, but the posts don't appear in masonry columns as they do on the archives.

How can I make the search results page consistent with the archives?

Thanks!

Hi Sasha,

You can use this snippet to enable columns for search:

add_filter( 'generate_blog_columns', function( $columns ) {
    if ( is_search() ) {
        return true;
    }

    return $columns;
} );

And this to add masonry:

add_filter( 'generate_blog_masonry','tu_portfolio_masonry' );
function tu_portfolio_masonry( $masonry ) {
    if ( is_search()) {
        return 'true';
    }

    return $masonry;
}

Another flawless solution – thanks Ying!

You are welcome :)

This archived topic is closed to new replies.