Snippets

Rik Kendell Posts per page for custom post type archive

Created by Rik Kendell

File functions.php Added

  • Ignore whitespace
  • Hide word diff
+// Posts per page for custom post type Case Studies
+function cpt_post_per_page( $query ) {
+    if ( !is_admin() && $query->is_main_query() && is_post_type_archive( 'case-studies' ) ) {
+        $query->set( 'posts_per_page', '10' );
+    }
+}
+add_action( 'pre_get_posts', 'cpt_post_per_page' );
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.