title: How do I display a custom archive page under a custom post in Wordpress?
body: <p>I am working on my Wordpress portfolio site and created a custom post type for my portfolio section. When a user clicks on my portfolio link it takes them to archive-portfolio.php which displays a gallery of all my projects and when they click on a project it takes them to single-portfolio.php displaying the associated project.</p>
  
  <p>Everything is working how it should and is styled correctly, but now I would like to have the gallery, which is on archive-portfolio.php, also display under each project, which is on single-portfolio.php, making navigation between projects easy. It would also be great if when it displayed the gallery the link for the project that the user was on was excluded from the gallery.</p>
  
  <p>I've tried inserting</p>
  
  <pre><code>&lt;?php wp_get_archives(); ?&gt;
  </code></pre>
  
  <p>into my single-portfolio.php template, but I couldn't seem to get it to work how I wanted. I couldn't get it to grab my custom posts and it would just display a month link that linked to my regular posts. I need it to just display my custom posts and the gallery that is on archive-portfolio.php. (Basically I just want to insert archive-portfolio.php into single-portfolio.php under the content of single-portfolio.php)</p>
  
  <p>This is my first Wordpress site and I am learning it all on my own as I go. I've tried searching for a solution on my own, but everything I find seems to just be about how to create a custom post type, which I already figured out. I am still developing my site locally which is why I can't link to it right now, but to give you an idea of what I'm going for you can check out this site which was made with Cargo:</p>
  
  <p><a href="http://www.timboelaars.nl/help-ink" rel="nofollow" title="this is an example of what I am going for">http://www.timboelaars.nl/help-ink</a></p>
  
  <p>Basically, I want the same functionality as the example site; I just want the gallery to display under the project.</p>
  
  <p>Like always, any help would be much appreciated! I've been struggling with a solution for this for a couple of days now and have been avoiding it, but the site is almost done and it can't be avoided anymore. I could really use some help on this. Thanks in advance!
  <br>
  <br>
  <br>
  <br>
  <em>(EDIT: As requested by the comment below, here is what my custom php files look like)</em></p>
  
  <h2>archive-portfolio.php:</h2>
  
  <pre><code>&lt;!-- get_header --&gt;
  &lt;?php get_header(); ?&gt;
  &lt;!-- END get_header --&gt;         
  
              &lt;!-- #content --&gt;
              &lt;div id="content"&gt;
  
                  &lt;!-- #inner-content --&gt;
                  &lt;div id="inner-content" class="wrap clearfix"&gt;
  
                      &lt;!-- #main --&gt;
                      &lt;div id="main" class="twelvecol first clearfix" role="main"&gt;
  
                          &lt;!-- have_posts --&gt;
                          &lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt;
  
                          &lt;!-- article --&gt;
                          &lt;article id="post-&lt;?php the_ID(); ?&gt;" &lt;?php post_class(); ?&gt; role="article"&gt;
  
                              &lt;!-- .entry-content --&gt;
                              &lt;section class="entry-content clearfix portfolio-gallery"&gt;
  
                                  &lt;!-- PORTFOLIO PROJECT LINK --&gt;
                                  &lt;a href="&lt;?php the_permalink() ?&gt;"&gt;
  
                                      &lt;!-- .portfolio-project --&gt;
                                      &lt;figure class="portfolio-project"&gt;
  
                                          &lt;!-- custom header --&gt;
                                          &lt;header class="portfolio-project-title"&gt;
                                              &lt;h1 class="bigtext"&gt;
                                                  &lt;div&gt;
                                                      &lt;?php
                                                          global $post;
                                                              $text = get_post_meta( $post-&gt;ID, 'juroto_custom_header', true );
                                                          echo $text;
                                                      ?&gt;
                                                  &lt;/div&gt;
                                              &lt;/h1&gt;                                   
                                          &lt;/header&gt; &lt;!-- END custom header --&gt;                                    
  
                                          &lt;!-- the_excerpt --&gt;
                                          &lt;figcaption class="portfolio-project-excerpt"&gt;
                                              &lt;?php the_excerpt(); ?&gt;
                                          &lt;/figcaption&gt; &lt;!-- END the_excerpt --&gt;
  
                                          &lt;!-- .black-filter --&gt;
                                          &lt;div class="black-filter"&gt;&lt;/div&gt;
                                          &lt;!-- END .black-filter --&gt;
  
                                          &lt;!-- featured image --&gt;
                                          &lt;?php
                                              if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
                                                  the_post_thumbnail('thumbnail-bw', array('class'=&gt;'bw-image-fade'));
                                                  the_post_thumbnail('thumbnail');
                                              } 
                                          ?&gt; &lt;!-- END featured image --&gt;
  
                                      &lt;/figure&gt; &lt;!-- END .portfolio-project --&gt;
  
                                  &lt;/a&gt; &lt;!-- END PORTFOLIO PROJECT LINK --&gt;
  
                              &lt;/section&gt; &lt;!-- END .entry-content --&gt;
  
                          &lt;/article&gt; &lt;!-- END article --&gt;
  
                          &lt;?php endwhile; ?&gt; &lt;!-- END have_posts --&gt;
  
                          &lt;?php else : ?&gt;
  
                              &lt;!-- #post-not-found --&gt;
                              &lt;article id="post-not-found" class="hentry clearfix"&gt;
                                  &lt;header class="article-header"&gt;
                                      &lt;h1&gt;&lt;?php _e("Oops, Post Not Found!", "bonestheme"); ?&gt;&lt;/h1&gt;
                                  &lt;/header&gt;
                                  &lt;section class="entry-content"&gt;
                                      &lt;p&gt;&lt;?php _e("Uh Oh. Something is missing. Try double checking things.", "bonestheme"); ?&gt;&lt;/p&gt;
                                  &lt;/section&gt;
                                  &lt;footer class="article-footer"&gt;
                                      &lt;p&gt;&lt;?php _e("This is the error message in the custom posty type archive template.", "bonestheme"); ?&gt;&lt;/p&gt;
                                  &lt;/footer&gt;
                              &lt;/article&gt;
  
                          &lt;?php endif; ?&gt; &lt;!-- END #post-not-found --&gt;
  
                      &lt;/div&gt; &lt;!-- END #main --&gt;
  
                  &lt;/div&gt; &lt;!-- END #inner-content --&gt;
  
              &lt;/div&gt; &lt;!-- END #content --&gt;
  
  &lt;!-- get_footer --&gt;
  &lt;?php get_footer(); ?&gt;
  &lt;!-- END get_footer --&gt;
  </code></pre>
  
  <p>Basically I want to insert that loop that calls each article (or as I refer to it portfolio project) into single-portfolio.php under the project that is being shown. Here is what single-portfolio.php looks like.</p>
  
  <h2>single-portfolio.php:</h2>
  
  <pre><code>&lt;!-- get_header --&gt;
  &lt;?php get_header(); ?&gt;
  &lt;!-- END get_header --&gt;
  
              &lt;!-- #content --&gt;
              &lt;div id="content"&gt;
  
                  &lt;!-- #inner-content --&gt;
                  &lt;div id="inner-content" class="wrap clearfix"&gt;
  
                      &lt;!-- #main --&gt;
                      &lt;div id="main" class="twelvecol first clearfix" role="main"&gt;
  
                          &lt;!-- have_posts --&gt;
                          &lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt;
  
                          &lt;!-- article --&gt;
                          &lt;article id="post-&lt;?php the_ID(); ?&gt;" &lt;?php post_class('clearfix'); ?&gt; role="article"&gt;
  
                              &lt;!-- .article-header --&gt;
                              &lt;header class="article-header"&gt;
  
                                  &lt;!-- .bigtext --&gt;
                                  &lt;h1 class="bigtext"&gt;
                                      &lt;div&gt;
                                          &lt;!-- the_title --&gt;
                                          &lt;?php the_title(); ?&gt;
                                          &lt;!-- END the_title --&gt;
                                      &lt;/div&gt;
                                  &lt;/h1&gt; &lt;!-- END .bigtext --&gt;
  
                              &lt;/header&gt; &lt;!-- END article header --&gt;
  
                              &lt;!-- .entry-content --&gt;
                              &lt;section class="entry-content clearfix"&gt;
  
                                  &lt;!-- GALLERY --&gt;                                
                                  &lt;?php
                                      $jurotos_gallery = array( 
                                          // OPTIONS FOR THE GALLERY 
                                          'numberposts'       =&gt; -1, // Using -1 loads all posts or in this case images  
                                          'orderby'           =&gt; 'menu_order', // This ensures images are in the order set in the page media manager. To change the order of the images go to the post, click add media, click the drop down menu, select uploaded to this post, and just drag and drop the images in the order you want them to appear. When you're done just close the media manager, you don't need to update the post or insert image or anything.  
                                          'order'             =&gt; 'ASC', // ASC or DESC. ASC shows order as is in the media manager and DESC shows the reverse order (so the last image is first and so on)
                                          'post_mime_type'    =&gt; 'image', // Make sure it doesn't pull other resources, like videos  
                                          'post_parent'       =&gt; $post-&gt;ID, // *Important part - ensures the associated images are loaded 
                                          'post_status'       =&gt; null, 
                                          'post_type'         =&gt; 'attachment',
                                          'size'              =&gt; 'full',  // thumbnail, medium, large or full
                                          'include'           =&gt; '', // could choose to include something else
                                          'exclude'           =&gt; get_post_thumbnail_id( $post-&gt;ID ), // excludes thumbnail/featured image from being part of the gallery
                                      );  
  
                                      $images = get_children( $jurotos_gallery );
                                  ?&gt; 
  
                                  &lt;?php if($images){ ?&gt;  
                                      &lt;div class="flexslider"&gt;
                                          &lt;ul class="slides"&gt;
                                              &lt;?php foreach($images as $image){ ?&gt;  
                                                  &lt;li&gt;
                                                      &lt;img src="&lt;?php echo $image-&gt;guid; ?&gt;" alt="&lt;?php echo $image-&gt;post_title; ?&gt;" title="&lt;?php echo $image-&gt;post_title; ?&gt;" /&gt;
                                                  &lt;/li&gt; 
                                              &lt;?php } ?&gt;
                                          &lt;/ul&gt;  
                                      &lt;/div&gt;  
                                  &lt;?php } ?&gt;                              
                                  &lt;!-- END GALLERY --&gt;  
  
                                  &lt;!-- the_content --&gt;
                                  &lt;div id="accordion"&gt;
                                      &lt;h3&gt;Brief&lt;/h3&gt;
                                          &lt;div class="juroto-text-columns"&gt;
                                              &lt;?php the_content(); ?&gt;
                                          &lt;/div&gt;
                                  &lt;/div&gt;
                                  &lt;!-- END the_content --&gt;
  
                              &lt;/section&gt; &lt;!-- END .entry-content --&gt;
  
                          &lt;/article&gt; &lt;!-- END article --&gt;
  
                          &lt;?php endwhile; ?&gt; &lt;!-- END have_posts --&gt;          
  
                          &lt;?php else : ?&gt;
  
                              &lt;!-- #post-not-found --&gt;
                              &lt;article id="post-not-found" class="hentry clearfix"&gt;
                                  &lt;header class="article-header"&gt;
                                      &lt;h1&gt;&lt;?php _e("Oops, Post Not Found!", "bonestheme"); ?&gt;&lt;/h1&gt;
                                  &lt;/header&gt;
                                  &lt;section class="entry-content"&gt;
                                      &lt;p&gt;&lt;?php _e("Uh Oh. Something is missing. Try double checking things.", "bonestheme"); ?&gt;&lt;/p&gt;
                                  &lt;/section&gt;
                                  &lt;footer class="article-footer"&gt;
                                      &lt;p&gt;&lt;?php _e("This is the error message in the single-portfolio.php template.", "bonestheme"); ?&gt;&lt;/p&gt;
                                  &lt;/footer&gt;
                              &lt;/article&gt;
  
                          &lt;?php endif; ?&gt; &lt;!-- END #post-not-found --&gt;
  
                      &lt;/div&gt; &lt;!-- END #main --&gt;
  
                  &lt;/div&gt; &lt;!-- END #inner-content --&gt;
  
              &lt;/div&gt; &lt;!-- END #content --&gt;
  
  &lt;!-- get_footer --&gt;
  &lt;?php get_footer(); ?&gt;
  &lt;!-- END get_footer --&gt;
  </code></pre>
  
  <p><br>
  <br>
  <br>
  <br>
  <em>(EDIT: below is an excerpt of the loop from archive-portfolio.php that displays all my custom portfolio posts. I have these posts arranged and styled to look like a gallery of posts/projects. This is what I would like to have show up under a post/project when you are on the post/project page which is being displayed by single-portfolio.php. Basically I need to have this loop that gathers all the custom posts and arranges it into a gallery in single-portfolio.php under the loop in single-portfolio.php that gathers the information for that specific post/project, but I don't know how to do it. Is there some code like:</em> </p>
  
  <pre><code>&lt;?php get_archive-portfolio(); ?&gt; 
  </code></pre>
  
  <p><em>that I could use in single-portfolio.php to display the gallery of custom posts?)</em></p>
  
  <h2>loop from archive-portfolio.php that displays portfolio gallery:</h2>
  
  <pre><code>&lt;!-- have_posts --&gt;
  &lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt;
  
  &lt;!-- article --&gt;
  &lt;article id="post-&lt;?php the_ID(); ?&gt;" &lt;?php post_class(); ?&gt; role="article"&gt;
  
      &lt;!-- .entry-content --&gt;
      &lt;section class="entry-content clearfix portfolio-gallery"&gt;
  
          &lt;!-- PORTFOLIO PROJECT LINK --&gt;
          &lt;a href="&lt;?php the_permalink() ?&gt;"&gt;
  
              &lt;!-- .portfolio-project --&gt;
              &lt;figure class="portfolio-project"&gt;
  
                  &lt;!-- custom header --&gt;
                  &lt;header class="portfolio-project-title"&gt;
                      &lt;h1 class="bigtext"&gt;
                          &lt;div&gt;
                              &lt;?php
                                  global $post;
                                      $text = get_post_meta( $post-&gt;ID, 'juroto_custom_header', true );
                                  echo $text;
                              ?&gt;
                          &lt;/div&gt;
                      &lt;/h1&gt;                                   
                  &lt;/header&gt; &lt;!-- END custom header --&gt;                                    
  
                  &lt;!-- the_excerpt --&gt;
                  &lt;figcaption class="portfolio-project-excerpt"&gt;
                      &lt;?php the_excerpt(); ?&gt;
                  &lt;/figcaption&gt; &lt;!-- END the_excerpt --&gt;
  
                  &lt;!-- .black-filter --&gt;
                  &lt;div class="black-filter"&gt;&lt;/div&gt;
                  &lt;!-- END .black-filter --&gt;
  
                  &lt;!-- featured image --&gt;
                  &lt;?php
                      if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
                          the_post_thumbnail('thumbnail-bw', array('class'=&gt;'bw-image-fade'));
                          the_post_thumbnail('thumbnail');
                      } 
                  ?&gt; &lt;!-- END featured image --&gt;
  
              &lt;/figure&gt; &lt;!-- END .portfolio-project --&gt;
  
          &lt;/a&gt; &lt;!-- END PORTFOLIO PROJECT LINK --&gt;
  
      &lt;/section&gt; &lt;!-- END .entry-content --&gt;
  
  &lt;/article&gt; &lt;!-- END article --&gt;
  
  &lt;?php endwhile; ?&gt; &lt;!-- END have_posts --&gt;
  
  &lt;?php else : ?&gt;
  
      &lt;!-- #post-not-found --&gt;
      &lt;article id="post-not-found" class="hentry clearfix"&gt;
          &lt;header class="article-header"&gt;
              &lt;h1&gt;&lt;?php _e("Oops, Post Not Found!", "bonestheme"); ?&gt;&lt;/h1&gt;
          &lt;/header&gt;
          &lt;section class="entry-content"&gt;
              &lt;p&gt;&lt;?php _e("Uh Oh. Something is missing. Try double checking things.", "bonestheme"); ?&gt;&lt;/p&gt;
          &lt;/section&gt;
          &lt;footer class="article-footer"&gt;
              &lt;p&gt;&lt;?php _e("This is the error message in the custom posty type archive template.", "bonestheme"); ?&gt;&lt;/p&gt;
          &lt;/footer&gt;
      &lt;/article&gt;
  
  &lt;?php endif; ?&gt; &lt;!-- END #post-not-found --&gt;
  </code></pre>
  
  <p><br>
  <br>
  <br>
  <br>
  <em>(EDIT: below is portfolio.php which is a function file in my Wordpress theme that creates my custom-post-type:'portfolio', stores data for it, and creates a portfolio section in my admin area. This file also creates custom taxonomy for the custom post type and defines how many custom post types will be shown per page on its archive page, which I set to be all of the custom posts. I separated this file from my themes function file to keep it a bit more organized.)</em></p>
  
  <h2>portfolio.php function:</h2>
  
  <pre><code>&lt;?php
  /****************************************
  Creates Portfolio section in the admin 
  area and custom posts called Projects
  *****************************************/
  
  function create_portfolio_section() { 
      // creating (registering) the custom type 
      register_post_type( 'portfolio', /* (http://codex.wordpress.org/Function_Reference/register_post_type) *IMPORTANT: If you change this, remember to resave/update permalinks from Wordpress admin menu under Setting/Permalinks for the page to display properly. Forgetting to do this will most likely lead you to the 404 error page */
          // All the options for this post type
          array('labels' =&gt; array(
              'name' =&gt; __('Portfolio', 'bonestheme'), /* This is the Title of the Group */
              'singular_name' =&gt; __('Project', 'bonestheme'), /* This is the individual type */
              'all_items' =&gt; __('All Projects', 'bonestheme'), /* the all items menu item */
              'add_new' =&gt; __('Add New Project', 'bonestheme'), /* The add new menu item */
              'add_new_item' =&gt; __('Add New Project', 'bonestheme'), /* Add New Display Title */
              'edit' =&gt; __( 'Edit Project', 'bonestheme' ), /* Edit Dialog */
              'edit_item' =&gt; __('Edit Project', 'bonestheme'), /* Edit Display Title */
              'new_item' =&gt; __('New Project', 'bonestheme'), /* New Display Title */
              'view_item' =&gt; __('View Project', 'bonestheme'), /* View Display Title */
              'search_items' =&gt; __('Search Project', 'bonestheme'), /* Search Project Title */ 
              'not_found' =&gt;  __('No Projects found', 'bonestheme'), /* This displays if there are no entries yet */ 
              'not_found_in_trash' =&gt; __('No Projects found in the Trash', 'bonestheme'), /* This displays if there is nothing in the trash */
              'parent_item_colon' =&gt; ''
              ), /* end of arrays */
              'description' =&gt; __( 'This is a Portfolio Project', 'bonestheme' ), /* Project Description */
              'public' =&gt; true,
              'publicly_queryable' =&gt; true,
              'exclude_from_search' =&gt; false,
              'show_ui' =&gt; true,
              'query_var' =&gt; true,
              'menu_position' =&gt; 5, /* this is what order you want it to appear in on the left hand side menu */ 
              'menu_icon' =&gt; get_stylesheet_directory_uri() . '/library/images/custom-post-icon.png', /* the icon for the custom post type menu */
              'rewrite'   =&gt; array( 'slug' =&gt; 'portfolio', 'with_front' =&gt; false ), /* you can specify its url slug *IMPORTANT: If you change this, remember to resave/update permalinks from Wordpress admin menu under Setting/Permalinks for the page to display properly. Forgetting to do this will most likely lead you to the 404 error page */
              'has_archive' =&gt; 'portfolio', /* you can rename the slug here *IMPORTANT: If you change this, remember to resave/update permalinks from Wordpress admin menu under Setting/Permalinks for the page to display properly. Forgetting to do this will most likely lead you to the 404 error page */
              'capability_type' =&gt; 'post',
              'hierarchical' =&gt; false,
              /* the next one is important, it tells what's enabled in the post editor */
              'supports' =&gt; array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'sticky')
          ) /* end of options */
      ); /* end of register post type */
  
      /* this adds your post categories to the Portfolio section */
      register_taxonomy_for_object_type('category', 'portfolio');
      /* this adds your post tags to the Portfolio section */
      register_taxonomy_for_object_type('post_tag', 'portfolio');
  
  } 
  
      // adding the function to the Wordpress init
      add_action( 'init', 'create_portfolio_section');
  
      /*
      for more information on taxonomies, go here:
      http://codex.wordpress.org/Function_Reference/register_taxonomy
      */
  
      // this adds Portfolio Categories to the Portfolio section
      register_taxonomy( 'portfolio_cat', 
          array('portfolio'), /* if you change the name of register_post_type( 'portfolio', then you have to change this */
          array('hierarchical' =&gt; true,     /* if this is true, it acts like categories */             
              'labels' =&gt; array(
                  'name' =&gt; __( 'Portfolio Categories', 'bonestheme' ), /* name of the custom taxonomy */
                  'singular_name' =&gt; __( 'Portfolio Category', 'bonestheme' ), /* single taxonomy name */
                  'search_items' =&gt;  __( 'Search Portfolio Categories', 'bonestheme' ), /* search title for taxomony */
                  'all_items' =&gt; __( 'All Portfolio Categories', 'bonestheme' ), /* all title for taxonomies */
                  'parent_item' =&gt; __( 'Parent Portfolio Category', 'bonestheme' ), /* parent title for taxonomy */
                  'parent_item_colon' =&gt; __( 'Parent Portfolio Category:', 'bonestheme' ), /* parent taxonomy title */
                  'edit_item' =&gt; __( 'Edit Portfolio Category', 'bonestheme' ), /* edit custom taxonomy title */
                  'update_item' =&gt; __( 'Update Portfolio Category', 'bonestheme' ), /* update title for taxonomy */
                  'add_new_item' =&gt; __( 'Add New Portfolio Category', 'bonestheme' ), /* add new title for taxonomy */
                  'new_item_name' =&gt; __( 'New Portfolio Category Name', 'bonestheme' ) /* name title for taxonomy */
              ),
              'show_admin_column' =&gt; true, 
              'show_ui' =&gt; true,
              'query_var' =&gt; true,
              'rewrite' =&gt; array( 'slug' =&gt; 'custom-slug' ),
          )
      );   
  
      // this adds Portfolio Tags to the Portfolio section
      register_taxonomy( 'portfolio_tag', 
          array('portfolio'), /* if you change the name of register_post_type( 'portfolio', then you have to change this */
          array('hierarchical' =&gt; false,    /* if this is false, it acts like tags */                
              'labels' =&gt; array(
                  'name' =&gt; __( 'Portfolio Tags', 'bonestheme' ), /* name of the custom taxonomy */
                  'singular_name' =&gt; __( 'Portfolio Tag', 'bonestheme' ), /* single taxonomy name */
                  'search_items' =&gt;  __( 'Search Portfolio Tags', 'bonestheme' ), /* search title for taxomony */
                  'all_items' =&gt; __( 'All Portfolio Tags', 'bonestheme' ), /* all title for taxonomies */
                  'parent_item' =&gt; __( 'Parent Portfolio Tag', 'bonestheme' ), /* parent title for taxonomy */
                  'parent_item_colon' =&gt; __( 'Parent Portfolio Tag:', 'bonestheme' ), /* parent taxonomy title */
                  'edit_item' =&gt; __( 'Edit Portfolio Tag', 'bonestheme' ), /* edit custom taxonomy title */
                  'update_item' =&gt; __( 'Update Portfolio Tag', 'bonestheme' ), /* update title for taxonomy */
                  'add_new_item' =&gt; __( 'Add New Portfolio Tag', 'bonestheme' ), /* add new title for taxonomy */
                  'new_item_name' =&gt; __( 'New Portfolio Tag Name', 'bonestheme' ) /* name title for taxonomy */
              ),
              'show_admin_column' =&gt; true,
              'show_ui' =&gt; true,
              'query_var' =&gt; true,
          )
      ); 
  
      /*
          looking for custom meta boxes?
          check out this fantastic tool:
          https://github.com/jaredatch/Custom-Metaboxes-and-Fields-for-WordPress
      */
  
  
  
  // Custom Posts Per Page
  function portfolio_posts_per_page($query)
  {
      switch ( $query-&gt;query_vars['post_type'] )
      {
          case 'portfolio':  // Post Type named 'portfolio'
              $query-&gt;query_vars['posts_per_page'] = -1; // -1 makes all posts shown on one page, positive numbers show that number of posts per page.
              break;
  
          // If you have more custom post types and you want to have the posts per page different than the journal/blog settings copy and past the code above and assign proper post type name and desired posts per page
          // EXAMPLE
          /*
          case '&lt;insert post type name here&gt;':  // Post Type named 'portfolio'
              $query-&gt;query_vars['posts_per_page'] = &lt;insert desiered posts per page number here&gt;; // -1 makes all posts shown on one page, positive numbers show that number of posts per page.
              break;
          */
  
          default:
              break;
      }
      return $query;
  }
  
  if( !is_admin() )
  {
      add_filter( 'pre_get_posts', 'portfolio_posts_per_page' );
  }
  
  ?&gt;
  </code></pre>