Created
July 15, 2020 03:10
-
-
Save jbd91/a5ae15d84094c03df039e3aca3a76532 to your computer and use it in GitHub Desktop.
Set pagination posts per page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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