Archived topic
Choosing numbers of post shown on search
3 replies · Started by Christiano on October 11, 2022
Viewing posts 1–4 of 4
How can I choose the number of entries shown when performing a search?
THANKS IN ADVANCE! 🤗
Hi there,
Try this PHP snippet:
function search_posts_per_page( $query ) {
if ( $query->is_search() && $query->is_main_query() ) {
$query->set( 'posts_per_page', 10 );
}
}
add_action( 'pre_get_posts', 'search_posts_per_page' );
Adding PHP: https://docs.generatepress.com/article/adding-php/
Let me know if this helps :)
Thanks Leo, it works perfectly! 🤗
No problem :)
This archived topic is closed to new replies.