{"id":503,"date":"2012-04-09T23:51:17","date_gmt":"2012-04-09T14:51:17","guid":{"rendered":"http:\/\/www.santoshkori.com\/blog\/?p=503"},"modified":"2012-08-23T17:28:10","modified_gmt":"2012-08-23T08:28:10","slug":"how-to-add-wordpress-pagination-without-plugins","status":"publish","type":"post","link":"https:\/\/www.santoshkori.com\/blog\/how-to-add-wordpress-pagination-without-plugins\/","title":{"rendered":"how to add WordPress pagination without plugins"},"content":{"rendered":"<p>Simply paste the following code where you want to display your pagination<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\nglobal $wp_query;\r\n$total = $wp_query-&gt;max_num_pages;\r\n\/\/ only bother with the rest if we have more than 1 page!\r\nif ( $total &gt; 1 )  {\r\n     \/\/ get the current page\r\n     if ( !$current_page = get_query_var('paged') )\r\n          $current_page = 1;\r\n     \/\/ structure of &quot;format&quot; depends on whether we're using pretty permalinks\r\n     $format = empty( get_option('permalink_structure') ) ? '&amp;page=%#%' : 'page\/%#%\/';\r\n     echo paginate_links(array(\r\n          'base' =&gt; get_pagenum_link(1) . '%_%',\r\n          'format' =&gt; $format,\r\n          'current' =&gt; $current_page,\r\n          'total' =&gt; $total,\r\n          'mid_size' =&gt; 4,\r\n          'type' =&gt; 'list'\r\n     ));\r\n}\r\n<\/pre>\n<p>enjoy&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Simply paste the following code where you want to display your pagination global $wp_query; $total = $wp_query-&gt;max_num_pages; \/\/ only bother with the rest if we have more than 1 page! if ( $total &gt; 1 ) { \/\/ get the current page if ( !$current_page = get_query_var(&#8216;paged&#8217;) ) $current_page = 1; \/\/ structure of &quot;format&quot; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[184],"tags":[224,222,223,725],"class_list":["post-503","post","type-post","status-publish","format-standard","hentry","category-wordpress-tip-and-tricks","tag-add-wordpress-pagination-without-plugins","tag-easy-wordpress-pagination-without-plugins","tag-how-to-add-wordpress-pagination-without-plugins","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/posts\/503","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/comments?post=503"}],"version-history":[{"count":3,"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/posts\/503\/revisions"}],"predecessor-version":[{"id":505,"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/posts\/503\/revisions\/505"}],"wp:attachment":[{"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/media?parent=503"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/categories?post=503"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/tags?post=503"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}