Site logo

[Resolved] Search result page not even

Home Forums Support [Resolved] Search result page not even

Home Forums Support Search result page not even

  • This topic has 8 replies, 2 voices, and was last updated 4 years ago by Leo.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #2153329
    Dong

    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.

    #2153357
    Leo
    Staff
    Customer Support

    Hi there,

    What is the number set for the Blog pages show at most setting in WP readings setting?
    https://wordpress.org/support/article/settings-reading-screen/

    #2153359
    Dong

    14, Leo.

    #2153362
    Leo
    Staff
    Customer Support

    So sounds like setting it to 15 might work better?

    Or any numbers that’s multiple of 3.

    #2153364
    Dong

    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?

    #2153366
    Dong

    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.

    #2153367
    Leo
    Staff
    Customer Support

    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/

    #2153372
    Dong

    Got it. Thanks, Leo.

    #2153374
    Leo
    Staff
    Customer Support

    No problem 🙂

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