{"id":3940940,"date":"2013-07-18T12:43:22","date_gmt":"2013-07-18T12:43:22","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/adding-pagination-to-a-custom-theme\/"},"modified":"2016-08-21T03:03:28","modified_gmt":"2016-08-21T03:03:28","slug":"adding-pagination-to-a-custom-theme","status":"closed","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/adding-pagination-to-a-custom-theme\/","title":{"rendered":"Adding pagination to a custom theme"},"content":{"rendered":"<p>I&#8217;ve built a custom theme and I would like to add pagination to it.  <\/p>\n<p>In my search.php file I have this loop set up:<\/p>\n<pre><code>&lt;?php $search_count = 0;\n\t$search = new WP_Query(&quot;s=$s &amp; showposts=-1&quot;);\n\tif($search-&gt;have_posts()) : while($search-&gt;have_posts()) : $search-&gt;the_post();\n\t$search_count++; endwhile; endif; echo $search_count;?&gt; results for &#039;&lt;?php the_search_query(); ?&gt;&#039;\n&lt;\/h4&gt;\n&lt;ol class=&quot;search-result&quot;&gt;\n&lt;?php if(have_posts()) : while(have_posts()) : the_post(); ?&gt;\n&lt;li&gt;\n&lt;a href=&quot;&lt;?php the_permalink(); ?&gt;&quot;&gt;&lt;span class=&quot;the-title&quot;&gt;&lt;?php the_title(); ?&gt;&lt;\/span&gt;\n&lt;span class=&quot;the-exerpt&quot;&gt;&lt;?php the_excerpt(); ?&gt;&lt;\/span&gt;\n&lt;span class=&quot;the-permalink&quot;&gt;&lt;?php the_permalink(); ?&gt;&lt;\/span&gt;&lt;\/a&gt;\n&lt;\/li&gt;\n&lt;?php endwhile; endif; ?&gt;<\/code><\/pre>\n<p>How can I add pagination to this?<\/p>\n","protected":false},"template":"","class_list":["post-3940940","topic","type-topic","status-closed","hentry","topic-tag-loop","topic-tag-pagination","topic-tag-search-php"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/3940940","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/3940940\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=3940940"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}