Site logo

Archived topic

Search result page not even

8 replies · Started by Dong on March 13, 2022

Viewing posts 1–9 of 9

Hi guys,

IN my search result page, which uses a 3-column format, the posts of the last row are always shown in three volumes but sometimes just two, even though there are a lot more results that are not yet shown. Please help me fix it.

Here's an example:

https://dongknows.com/?s=armor

Thanks,

-Dong.

14, Leo.

So sounds like setting it to 15 might work better?

Or any numbers that's multiple of 3.

but then the front page would look crooked. But I think I got the issue now. Maybe I should change the search result page to 4-columns?

Nope, 4- or five-column search result also has the same issue... looks like the only way is to use the search result with the same format as the front page or any archive page.

Try this snippet to change the posts per page setting in the search result page:

add_action( 'pre_get_posts', function( $query ) {
    if ( ! is_admin() && $query->is_main_query() ) {
        if ( is_search() ) {
            $query->set( 'posts_per_page', 15 );
        }
    }
} );

Adding PHP: https://docs.generatepress.com/article/adding-php/

Got it. Thanks, Leo.

No problem :)

This archived topic is closed to new replies.