Skip to content

Instantly share code, notes, and snippets.

@jbd91
Created July 15, 2020 03:10
Show Gist options
  • Save jbd91/a5ae15d84094c03df039e3aca3a76532 to your computer and use it in GitHub Desktop.
Save jbd91/a5ae15d84094c03df039e3aca3a76532 to your computer and use it in GitHub Desktop.
Set pagination posts per page
// functions.php
function custom_posts_per_page($query) {
if (is_home()) {
$query->set('posts_per_page', 8);
}
if (is_search()) {
$query->set('posts_per_page', -1);
}
if (is_archive()) {
$query->set('posts_per_page', 3);
} //endif
} //function
add_action('pre_get_posts', 'custom_posts_per_page');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment