If you created a category template for your design portfolio using the Genesis Modern Portfolio Theme, like my daughter did, you may want to change the number of posts per page.
Change Archive Posts Per Page in WordPress Settings
The easiest method to change the number of posts is to change it in the WordPress Settings.
From your WordPress Dashboard:
- Click on Settings > Reading.
- Change the “Blog pages show at most” to the number of design posts you want on your design category archive page.
Since your design posts are in 3 columns, you probably want to choose a multiple of 3. We chose 12 posts. You can leave all other settings on that page as they are.
Note that if you’re using Genesis, changing this WordPress Setting changes the number of posts for all your archive pages – all your category and tag pages. It does not change the number of posts on your blog page, since your blog uses the Genesis Blog Template.
Change Blog Posts Per Page in Genesis Theme Settings
To change the number of posts on your blog page in Genesis:
- In your WordPress menu, click Genesis > Theme Settings.
- Find the Blog Page Template section.
- Change the “Number of Posts to Show” to be what you want for your blog.
Change Posts Per Page Only for Your Category Archive
You can also change the number of posts for only your design category archive by adding a function to your child theme functions.php. This was added to the GitHub Gist to so all the code is in one place.
Open your functions.php in a text editor and add:
// Change posts per page in the design category
add_action( 'pre_get_posts', 'mp_design_cat_posts_per_page' );
function mp_design_cat_posts_per_page( $query ) {
if( $query->is_main_query() && is_category( 'design' ) && ! is_admin() ) {
$query->set( 'posts_per_page', '12' );
}
}
(This function is based on Customizing the WordPress Query from Bill Erickson.)
You will need to make two changes to this code before using it:
First change the category slug.
- Since our category slug is “design”, we used
is_category( 'design' )
- You want to change it to use your slug.
- If your slug is “design-portfolio”, you would use
is_category( 'design-portfolio' )
You also want to change the ( 'posts_per_page', '12' )
.
- Change the number 12 to be the number of posts you want on each of your design category archive pages.
This was added to the GitHub Gist to so all the code is in one place.
Now you can have a custom number of posts per page for only your design category archive.
Leave a Reply