title: paginate custom post type in single page WordPress
body: <p>I have two <strong><em>custom posts type</em></strong> :</p>
  
  <ul>
  <li><code>School</code> </li>
  <li><code>teacher</code></li>
  </ul>
  
  <p>and there are connected using <strong><em>post 2 post</em></strong> plugin. so when I display a school single page <code>school-single.php,</code> it's show me school informations and list of teachers working in this school. everything working great.
  for me I want to display the list of teachers by pagination and this not working.</p>
  
  <p><strong>Register Custom Post Type</strong></p>
  
  <pre><code>function school() {
  
      $labels = array(
          'name'                  =&gt; _x( 'schools', 'Post Type General Name', 'text_domain' ),
          'singular_name'         =&gt; _x( 'school', 'Post Type Singular Name', 'text_domain' ),
          'menu_name'             =&gt; __( 'school', 'text_domain' ),
          'name_admin_bar'        =&gt; __( 'school', 'text_domain' ),
          'parent_item_colon'     =&gt; __( 'Parent Item:', 'text_domain' ),
          'all_items'             =&gt; __( 'All Items', 'text_domain' ),
          'add_new_item'          =&gt; __( 'Add New Item', 'text_domain' ),
          'add_new'               =&gt; __( 'Add New', 'text_domain' ),
          'new_item'              =&gt; __( 'New Item', 'text_domain' ),
          'edit_item'             =&gt; __( 'Edit Item', 'text_domain' ),
          'update_item'           =&gt; __( 'Update Item', 'text_domain' ),
          'view_item'             =&gt; __( 'View Item', 'text_domain' ),
          'search_items'          =&gt; __( 'Search Item', 'text_domain' ),
          'not_found'             =&gt; __( 'Not found', 'text_domain' ),
          'not_found_in_trash'    =&gt; __( 'Not found in Trash', 'text_domain' ),
          'items_list'            =&gt; __( 'Items list', 'text_domain' ),
          'items_list_navigation' =&gt; __( 'Items list navigation', 'text_domain' ),
          'filter_items_list'     =&gt; __( 'Filter items list', 'text_domain' ),
      );
      $args = array(
          'label'                 =&gt; __( 'school', 'text_domain' ),
          'description'           =&gt; __( 'school Description', 'text_domain' ),
          'labels'                =&gt; $labels,
          'supports'              =&gt; array( 'title', 'editor', ),
          'taxonomies'            =&gt; array( 'category', 'post_tag' ),
          'hierarchical'          =&gt; false,
          'public'                =&gt; true,
          'show_ui'               =&gt; true,
          'show_in_menu'          =&gt; true,
          'menu_position'         =&gt; 5,
          'show_in_admin_bar'     =&gt; true,
          'show_in_nav_menus'     =&gt; true,
          'can_export'            =&gt; true,
          'has_archive'           =&gt; true,        
          'exclude_from_search'   =&gt; false,
          'publicly_queryable'    =&gt; true,
          'capability_type'       =&gt; 'page',
      );
      register_post_type( 'school', $args );
  
  }
  add_action( 'init', 'school', 0 );
  </code></pre>
  
  <p><strong>Pagination code :</strong> By <a href="http://fellowtuts.com/wordpress/bootstrap-3-pagination-in-wordpress/" rel="nofollow noreferrer">wp_bs_pagination</a></p>
  
  <pre><code>&lt;?php
  /**
   * WordPress Bootstrap Pagination
   */
  
  add_action( 'wp_loaded', 'the_pagination' );
  
  
  // Bootstrap pagination function
  
  function the_pagination($pages = '', $range = 1) {  
  
      $showitems = ($range * 2) + 1;  
  
      global $paged;
  
      if(empty($paged)) $paged = 1;
  
      if($pages == '') {
  
           global $wp_query; 
  
           $pages = $wp_query-&gt;max_num_pages;
  
           if(!$pages) {
              $pages = 1;
           }
  
      }   
  
      if(1 != $pages) {
  
          echo '&lt;div class="text-center"&gt;'; 
          echo '&lt;nav&gt;&lt;ul class="pagination"&gt;&lt;li class="disabled hidden-xs"&gt;&lt;span&gt;&lt;span aria-hidden="true"&gt;Page '.$paged.' of '.$pages.'&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;';
  
          if($paged &gt; 2 &amp;&amp; $paged &gt; $range+1 &amp;&amp; $showitems &lt; $pages) echo "&lt;li&gt;&lt;a href='".get_pagenum_link(1)."' aria-label='First'&gt;&amp;laquo;&lt;span class='hidden-xs'&gt; First&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;";
  
          if($paged &gt; 1 &amp;&amp; $showitems &lt; $pages) echo "&lt;li&gt;&lt;a href='".get_pagenum_link($paged - 1)."' aria-label='Previous'&gt;&amp;lsaquo;&lt;span class='hidden-xs'&gt; Previous&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;";
  
  
  
          for ($i=1; $i &lt;= $pages; $i++) {
  
              if (1 != $pages &amp;&amp;( !($i &gt;= $paged+$range+1 || $i &lt;= $paged-$range-1) || $pages &lt;= $showitems )) {
  
                  echo ($paged == $i)? "&lt;li class=\"active\"&gt;&lt;span&gt;".$i." &lt;span class=\"sr-only\"&gt;(current)&lt;/span&gt;&lt;/span&gt;
  
                  &lt;/li&gt;":"&lt;li&gt;&lt;a href='".get_pagenum_link($i)."'&gt;".$i."&lt;/a&gt;&lt;/li&gt;";
  
              }
          }
  
  
  
          if ($paged &lt; $pages &amp;&amp; $showitems &lt; $pages) echo "&lt;li&gt;&lt;a href=\"".get_pagenum_link($paged + 1)."\"  aria-label='Next'&gt;&lt;span class='hidden-xs'&gt;Next &lt;/span&gt;&amp;rsaquo;&lt;/a&gt;&lt;/li&gt;";  
  
          if ($paged &lt; $pages-1 &amp;&amp;  $paged+$range-1 &lt; $pages &amp;&amp; $showitems &lt; $pages) echo "&lt;li&gt;&lt;a href='".get_pagenum_link($pages)."' aria-label='Last'&gt;&lt;span class='hidden-xs'&gt;Last &lt;/span&gt;&amp;raquo;&lt;/a&gt;&lt;/li&gt;";
  
          echo "&lt;/ul&gt;&lt;/nav&gt;";
          echo "&lt;/div&gt;";
  
      }
  
  }
  </code></pre>
  
  <p><strong>The query that list teachers in school-single.php</strong></p>
  
  <pre><code>&lt;?php
  
  $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
  $connected = new WP_Query( array(
      'connected_type' =&gt; 'school-teacher',
      'connected_items' =&gt; get_queried_object_id(),
      'nopaging' =&gt; false,
      'posts_per_page' =&gt; 1,
      'paged' =&gt; $paged,
      ),
  ) );
  
  if ( $connected-&gt;have_posts() ) :
      while ( $connected-&gt;have_posts() ) : $connected-&gt;the_post();
      ....
      endwhile;
  endif;
  
  /* Pagination */
  the_pagination($connected-&gt;max_num_pages);
  
  /* Restore original Post Data */
  wp_reset_postdata();
  </code></pre>
  
  <p><strong>The pagination displays correctly:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/MycCV.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MycCV.jpg" alt="Pagination"></a></p>
  
  <p>the url of the page 2 is : <code>wwww.mywebsite.com/school/school_name/page/2</code> when I click on it redirect me to same page.  <code>wwww.mywebsite.com/school/school_name</code>.</p>
  
  <p>I think the single page doesn't accept parameter in url. Anyway can someone propose a solution !?</p>