title: Adding pagination to wordpress amp-wp plugin
body: <p>I am using the WordPress AMP plugin by Automattic and trying to figure out how to keep my pagination functioning. I have many very long posts and the plugin is converting all my post to single AMP pages and removing the pagination that is implemented using the  comment block that is available in WordPress. This is the code I use for the Desktop and Responsive version of my blog but it doesn't work on the AMP pages. Any help functions or edits to my pagination function I can make to get my pagination working correctly again would be great. I am also opening to editing the plugin if there is a fix that way.</p>
  
  <pre><code>function new_pagination($pages = '', $range = 1) {
      $showitems = ($range * 2)+1;
      global $paged, $page;
  
      if(empty($paged)) $paged = 1;
  
      if(empty($page)) $page = 1;
  
      if($pages == '') {
          global $wp_query, $numpages;
          if ( is_single() ) { 
              $pages = $numpages;
          }else{
              $pages = $wp_query-&gt;max_num_pages;
          }
          if(!$pages) {
              $pages = 1;
          }
      }
  
      if(1 != $pages) {
          echo "&lt;div class='pagination'&gt;&lt;ul&gt;";
          if ( is_single() ) { 
              if(($page &gt; 2 &amp;&amp; $page &gt; $range+1 &amp;&amp; $showitems &lt; $pages) &amp;&amp; ($page &gt; 1 &amp;&amp; $showitems &lt; $pages)) {
                  echo "&lt;li class='mobile-show'&gt;&lt;a href='".get_permalink().--$page."/'&gt;Prev&lt;/a&gt;&lt;/li&gt;";
                  echo "&lt;li class='first'&gt;&lt;a href='".get_permalink()."'&gt;First&lt;/a&gt;&lt;/li&gt;";
                  $page++;
              }else{
                  if($page &gt; 1 &amp;&amp; $showitems &lt; $pages) {
                      echo "&lt;li&gt;&lt;a href='".get_permalink().--$page."/'&gt;Prev&lt;/a&gt;&lt;/li&gt;";
                      $page++;
                  }
                  if($page &gt; 2 &amp;&amp; $page &gt; $range+1 &amp;&amp; $showitems &lt; $pages) echo "&lt;li class='first'&gt;&lt;a href='".get_permalink()."'&gt;First&lt;/a&gt;&lt;/li&gt;";
  
              }
          }else{
              if(($paged &gt; 2 &amp;&amp; $paged &gt; $range+1 &amp;&amp; $showitems &lt; $pages) &amp;&amp; ($paged &gt; 1 &amp;&amp; $showitems &lt; $pages)) {
                  echo "&lt;li class='mobile-show'&gt;&lt;a href='".get_pagenum_link($paged - 1)."'&gt;Prev&lt;/a&gt;&lt;/li&gt;";
                  echo "&lt;li class='first'&gt;&lt;a href='".get_pagenum_link(1)."'&gt;First&lt;/a&gt;&lt;/li&gt;";
              }else{
                  if($paged &gt; 1 &amp;&amp; $showitems &lt; $pages) echo "&lt;li class='mobile-show'&gt;&lt;a href='".get_pagenum_link($paged - 1)."'&gt;Prev&lt;/a&gt;&lt;/li&gt;";
                  if($paged &gt; 2 &amp;&amp; $paged &gt; $range+1 &amp;&amp; $showitems &lt; $pages) echo "&lt;li class='first'&gt;&lt;a href='".get_pagenum_link(1)."'&gt;First&lt;/a&gt;&lt;/li&gt;";
              }
          }
          for ($i=1; $i &lt;= $pages; $i++) {
              if ( is_single() ) { 
                  if (1 != $pages &amp;&amp;( !($i &gt;= $page+$range+1 || $i &lt;= $page-$range-1) || $pages &lt;= $showitems )) {
                      echo ($page == $i)? "&lt;li class='active'&gt;&lt;span class='current'&gt;".$i."&lt;/span&gt;&lt;/li&gt;":"&lt;li&gt;&lt;a href='".get_permalink()."".$i."/' class='inactive' &gt;".$i."&lt;/a&gt;&lt;/li&gt;";
                  }
              }else{
                  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 class='current'&gt;".$i."&lt;/span&gt;&lt;/li&gt;":"&lt;li&gt;&lt;a href='".get_pagenum_link($i)."' class='inactive' &gt;".$i."&lt;/a&gt;&lt;/li&gt;";
                  }
              }
          }
          if ( is_single() ) { 
              if(($page &lt; $pages-1 &amp;&amp; $page+$range-1 &lt; $pages &amp;&amp; $showitems &lt; $pages) &amp;&amp; ($page &lt; $pages &amp;&amp; $showitems &lt; $pages)) {
                  echo "&lt;li class='last'&gt;&lt;a href='".get_permalink().$pages."/'&gt;Last&lt;/a&gt;&lt;/li&gt;";
                  echo "&lt;li class='mobile-show'&gt;&lt;a href='".get_permalink().++$page."/'&gt;Next&lt;/a&gt;&lt;/li&gt;";
              }else {
                  if ($page &lt; $pages-1 &amp;&amp; $page+$range-1 &lt; $pages &amp;&amp; $showitems &lt; $pages) echo "&lt;li class='last'&gt;&lt;a href='".get_permalink().$pages."/'&gt;Last&lt;/a&gt;&lt;/li&gt;";
                  if ($page &lt; $pages &amp;&amp; $showitems &lt; $pages) echo "&lt;li class='mobile-show'&gt;&lt;a href='".get_permalink().++$page."/'&gt;Next&lt;/a&gt;&lt;/li&gt;";
              }
          }else{
              if(($paged &lt; $pages-1 &amp;&amp; $paged+$range-1 &lt; $pages &amp;&amp; $showitems &lt; $pages) &amp;&amp; ($paged &lt; $pages &amp;&amp; $showitems &lt; $pages)) {
                  echo "&lt;li class='last'&gt;&lt;a href='".get_pagenum_link($pages)."'&gt;Last&lt;/a&gt;&lt;/li&gt;";
                  echo "&lt;li class='mobile-show'&gt;&lt;a href='".get_pagenum_link($paged + 1)."'&gt;Next&lt;/a&gt;&lt;/li&gt;";
              }else {
                  if ($paged &lt; $pages-1 &amp;&amp; $paged+$range-1 &lt; $pages &amp;&amp; $showitems &lt; $pages) echo "&lt;li class='last'&gt;&lt;a href='".get_pagenum_link($pages)."'&gt;Last&lt;/a&gt;&lt;/li&gt;";
                  if ($paged &lt; $pages &amp;&amp; $showitems &lt; $pages) echo "&lt;li class='mobile-show'&gt;&lt;a href='".get_pagenum_link($paged + 1)."'&gt;Next&lt;/a&gt;&lt;/li&gt;";
              }
          }
  
          echo "&lt;/ul&gt;&lt;/div&gt;\n";
      }
  }
  </code></pre>