Limit post per search page
-
I found this code that lets you limit the number of post in the categories, I wonder if you can do the same but for the search results.
for categories:
function limit_posts_per_page() { if ( is_category() ) return 2; else return 5; // default: 5 posts per page } add_filter('pre_option_posts_per_page', 'limit_posts_per_page');
for archive page:
function limit_posts_per_archive_page() { if ( is_category() ) set_query_var('posts_per_archive_page', 2); // or use variable key: posts_per_page } add_filter('pre_get_posts', 'limit_posts_per_archive_page');
Source: https://zeo.my/wordpress-limit-posts-per-page/
Regards
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Limit post per search page’ is closed to new replies.