Will McLean is a designer and artist working in the Central Coast of NSW where he lives with his wife and 2 children.

Will is a meticulous developer and favours simplicity and clarity within his code. He can’t stand writing things twice so searches for any way to automate. His experiments can be found in the Exercises section of this site.

Will designs within systems. No project is too small for a design system. He favours the unusual, if not, how can he progress? You can read about his work in the Case Studies section of this site.

Updated: October 31, 2017

This is a Knowledge Base post.

Correctly setting a different number of posts per page on a WordPress archive page

I found out recently that you should not be using a custom WP_Query on an archive page if you don’t want to cause major issues with your pagination. However, for this particular Custom Post Type archive page I needed to set a different number of posts per page than was set in the admin settings for the blog page. Without using a WP_Query I couldn’t find how to do this until I discovered the pre_get_posts action. So in my functions.php file I just added the code below:

function locations_posts_per_page( $query ) {
    if ( is_post_type_archive( 'locations' ) && !is_admin() ) {
        $query->set( 'posts_per_page', 500 );
add_action( 'pre_get_posts', 'locations_posts_per_page', 1 );