• Hello-

    I have implemented a previously documented solution to increase the number of search results beyond 5 per page using the following code in functions.php:

    add_filter('aws_posts_per_page','aws_posts_per_page');
    function aws_posts_per_page( $num ) {
        return 12;
    }

    This works, however it does not adjust the “breadcrumb” notification above the search results which still shows “Showing 1–5 of XX results”. How can this be adjusted to reflect the same number of max results as I have set in the code snippet? Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author ILLID

    (@mihail-barinov)

    Hi,

    Well all depends on your current WordPress theme. Please tell me the name of your theme.

    Regards

    Thread Starter nobaddreams

    (@nobaddreams)

    I am using Divi, no additional theme is installed beyond that. Thanks.

    Plugin Author ILLID

    (@mihail-barinov)

    Please try to use this addition code snippet

    add_filter( 'posts_request', 'aws_filter_posts_request', 9999, 2 );
    function aws_filter_posts_request( $request, $query  ) {
    
        $enabled = true;
    
        $post_type_product = ( $query->get( 'post_type' ) && is_string( $query->get( 'post_type' ) ) && $query->get( 'post_type' ) === 'product' ) ? true :
            ( ( isset( $_GET['post_type'] ) && $_GET['post_type'] === 'product' ) ? true : false );
    
        if ( ( isset( $query->query_vars['s'] ) && ! isset( $_GET['type_aws'] ) ) ||
            ! isset( $query->query_vars['s'] ) ||
            ! $query->is_search() ||
            ! $post_type_product
        ) {
            $enabled = false;
        }
    
        if ( $enabled ) {
            $posts_per_page = apply_filters( 'aws_posts_per_page', $query->get( 'posts_per_page' ) );
            $query->set( 'posts_per_page', $posts_per_page );
        }
    
        return $request;
    
    }
    Thread Starter nobaddreams

    (@nobaddreams)

    This seems to have worked well, much appreciated!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Increase number of search results per page’ is closed to new replies.