Different number of posts in regular loop and CPT category page
You’re halfway there. All you’re missing is the right hook: add_action( ‘pre_get_posts’, ‘num_posts_archive_project_ie’ ); The pre_get_posts hook fires after the main WP_Query object is instantiated but before it’s sent to the DB.