{"id":142812,"date":"2014-06-18T07:08:39","date_gmt":"2014-06-18T07:08:39","guid":{"rendered":"https:\/\/ru.wordpress.org\/support\/2014\/06\/18\/wp_query-%d0%b8-pagination\/"},"modified":"2014-06-18T07:08:39","modified_gmt":"2014-06-18T07:08:39","slug":"wp_query-%d0%b8-pagination","status":"closed","type":"topic","link":"https:\/\/ru.wordpress.org\/support\/topic\/wp_query-%d0%b8-pagination\/","title":{"rendered":"WP_Query \u0438 pagination"},"content":{"rendered":"<p>\u0418\u043c\u0435\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 category.php:<\/p>\n<pre><code>$all_posts = new WP_Query();\n$args = array(\n\t&#039;category_name&#039;  =&gt; &#039;blog&#039;,\n\t&#039;post_type&#039; =&gt; &#039;any&#039;,\n\t&#039;posts_per_page&#039; =&gt; 2,\n\t&#039;paged&#039; =&gt; $paged\n);\n$all_posts-&gt;query($args);\n$max_page = $all_posts-&gt;max_num_pages;\nif ( $all_posts-&gt;have_posts() ) :\nwhile ( $all_posts-&gt;have_posts() ) : $all_posts-&gt;the_post();\n\/\/ do action\nendwhile;\necho paginate_links( array(\n    &#039;base&#039; =&gt; str_replace( $big, &#039;%#%&#039;, esc_url( get_pagenum_link( $big ) ) ),\n    &#039;format&#039; =&gt; &#039;?paged=%#%&#039;,\n    &#039;current&#039; =&gt; max( 1, get_query_var(&#039;paged&#039;) ),\n    &#039;total&#039; =&gt; $max_page,\n    &#039;prev_text&#039;    =&gt; &#039;&lt;&#039;,\n    &#039;next_text&#039;    =&gt; &#039;&amp;gt&#039;\n) );\nendif;<\/code><\/pre>\n<p>\u0412\u0441\u0451 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e, \u043d\u043e \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0435 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0432\u044b\u0434\u0430\u0435\u0442 404.<br \/>\n\u0412 \u0447\u0435\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430?<\/p>\n","protected":false},"template":"","class_list":["post-142812","topic","type-topic","status-closed","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ru.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/142812","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ru.wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/ru.wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/ru.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/142812\/revisions"}],"wp:attachment":[{"href":"https:\/\/ru.wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=142812"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}