{"id":132,"date":"2014-02-07T11:34:24","date_gmt":"2014-02-07T11:34:24","guid":{"rendered":"http:\/\/www.eminozlem.com\/?p=132"},"modified":"2015-06-06T21:29:59","modified_gmt":"2015-06-06T21:29:59","slug":"page-template-pagination-fix","status":"publish","type":"post","link":"https:\/\/eminozlem.com\/tr\/page-template-pagination-fix\/","title":{"rendered":"Page template pagination fix"},"content":{"rendered":"<p>If you are using &#8220;page-template&#8221;s you&#8217;ll have problems with pagination since pages are not meant to display posts and some people frown upon using page-templates for custom archive display, but it&#8217;s sometimes the simplest way.<\/p>\n<p>Anyway the solution is 1.) to nullify the global $wpquery 2.) adding\u00a0 &#8216;paged&#8217; =&gt; $paged arg. before displaying your posts in a custom page template.<\/p>\n<pre class=\"lang:default decode:true\">$myargs=array(\r\n\t\t'post_type' =&gt; 'my_custom_type',\r\n\t\t'post_status' =&gt; 'publish',\r\n\t\t'ignore_sticky_posts'=&gt; 1,  \r\n\t\t'post__in' =&gt; $majids,\r\n\r\n\t\t'paged' =&gt; $paged\r\n\t);\r\n\t$myquery = new WP_Query( $myargs );\r\n\r\n\/\/ Pagination fix\r\n$wp_query   = NULL;\r\n$wp_query   = $majquery;\r\n\r\n if ( $majquery-&gt;have_posts()) : while ($majquery-&gt;have_posts()) : $majquery-&gt;the_post();\r\n \/\/ ... Loop here<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you are using &#8220;page-template&#8221;s you&#8217;ll have problems with pagination since pages are not meant to display posts and some people frown upon using page-templates for custom archive display, but it&#8217;s sometimes the simplest way. Anyway the solution is 1.) to nullify the global $wpquery 2.) adding\u00a0 &#8216;paged&#8217; =&gt; $paged arg. before displaying your posts&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"categories":[8,2],"tags":[36,35,37,4,10],"class_list":["post-132","post","type-post","status-publish","format-standard","hentry","category-note-to-self","category-wordpress","tag-custom-query","tag-page-template","tag-pagination","tag-wp","tag-wp_query"],"acf":[],"_links":{"self":[{"href":"https:\/\/eminozlem.com\/tr\/wp-json\/wp\/v2\/posts\/132","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eminozlem.com\/tr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eminozlem.com\/tr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eminozlem.com\/tr\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/eminozlem.com\/tr\/wp-json\/wp\/v2\/comments?post=132"}],"version-history":[{"count":0,"href":"https:\/\/eminozlem.com\/tr\/wp-json\/wp\/v2\/posts\/132\/revisions"}],"wp:attachment":[{"href":"https:\/\/eminozlem.com\/tr\/wp-json\/wp\/v2\/media?parent=132"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eminozlem.com\/tr\/wp-json\/wp\/v2\/categories?post=132"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eminozlem.com\/tr\/wp-json\/wp\/v2\/tags?post=132"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}