{"id":604,"date":"2026-08-02T10:00:00","date_gmt":"2026-08-02T08:00:00","guid":{"rendered":"https:\/\/aarkly.com\/?p=604"},"modified":"2026-07-21T12:31:07","modified_gmt":"2026-07-21T10:31:07","slug":"wordpress-pagination-guide-posts-comments","status":"publish","type":"post","link":"https:\/\/aarkly.com\/it\/wordpress-pagination-guide-posts-comments\/","title":{"rendered":"{\"translation\": \"Paginazione di WordPress: Una guida completa per paginare post e commenti\"}"},"content":{"rendered":"<p class=\"wp-block-paragraph\">Pagination is essential for WordPress sites with multiple pages of content. Without pagination, archive pages would load thousands of posts at once, destroying performance and overwhelming users. WordPress provides built-in pagination functions, but they require proper setup to work correctly with custom queries.<\/p><p class=\"wp-block-paragraph\">This guide covers how to implement pagination in WordPress, from basic post pagination to advanced AJAX-powered infinite scroll.<\/p><h2 class=\"wp-block-heading\">{\n  \"Default Post Pagination\": \"Paginazione predefinita dei post\"\n}<\/h2><p class=\"wp-block-paragraph\">WordPress handles pagination for the main query automatically. The Settings > Reading page lets you set the number of posts per page. The posts_nav_link() and paginate_links() functions generate pagination links for the main query. Use the_posts_pagination() for numbered pagination links with current page highlighting.<\/p><p class=\"wp-block-paragraph\">For post navigation within a single post \u2014 previous and next post links \u2014 use previous_post_link() and next_post_link(). These link to adjacent posts in chronological order.<\/p><h2 class=\"wp-block-heading\">```json\n{\n  \"Custom WP_Query Pagination\": \"Paginazione personalizzata WP_Query\"\n}\n```<\/h2><p class=\"wp-block-paragraph\">When you create a custom WP_Query, pagination doesn&#8217;t work automatically. Set the &#8216;paged&#8217; parameter to the current page number, and use max_num_pages from the query object to determine the total number of pages. Pass the query&#8217;s max_num_pages to paginate_links() for correct paginated output.<\/p><p class=\"wp-block-paragraph\">Get the current page number with get_query_var(&#8216;paged&#8217;) or max(1, get_query_var(&#8216;page&#8217;)). The first parameter works for archive pages, the second for single post pagination within a single page of content.<\/p><h2 class=\"wp-block-heading\">Comment Pagination<\/h2><p class=\"wp-block-paragraph\">Comments can be paginated with the Settings > Discussion page. Enable comment pagination and set the number of comments per page. WordPress handles comment pagination automatically with paginate_comments_links(). Use the comments_nav_link() function to display previous\/next comment navigation.<\/p><p class=\"wp-block-paragraph\">Comment pagination uses get_query_var(&#8216;cpage&#8217;) for the current page. The default order is oldest comments first, but you can change this in Discussion settings to show newest comments first.<\/p><h2 class=\"wp-block-heading\">AJAX Infinite Scroll<\/h2><p class=\"wp-block-paragraph\">Infinite scroll loads more posts when the user scrolls to the bottom of the page. Implement it with the WordPress REST API or admin-ajax.php. When the user reaches the bottom, your JavaScript sends a request for the next page of posts, appends them to the existing list, and updates the current page counter.<\/p><p class=\"wp-block-paragraph\">Use the Intersection Observer API to detect when the user reaches the bottom of the page \u2014 it&#8217;s more efficient than scroll event listeners. Load the next page via the REST API using \/wp\/v2\/posts?page=2&#038;per_page=10. Render the returned posts on the client side with JavaScript.<\/p><h2 class=\"wp-block-heading\">{\"SEO Considerations\": \"Considerazioni SEO\"}<\/h2><p class=\"wp-block-paragraph\">Paginated content creates duplicate content issues if not handled correctly. Use rel=&#8221;next&#8221; and rel=&#8221;prev&#8221; on paginated pages to indicate their relationship to search engines. Most SEO plugins add these automatically. Use canonical URLs pointing to the first page to consolidate ranking signals.<\/p><p class=\"wp-block-paragraph\">{\"text\": \"Lo scorrimento infinito pu\u00f2 causare problemi SEO perch\u00e9 i motori di ricerca potrebbero non indicizzare i contenuti caricati tramite AJAX. Utilizza il miglioramento progressivo \u2014 fornisci link di paginazione standard che funzionano senza JavaScript, poi migliora con lo scorrimento infinito. Questo garantisce che i motori di ricerca possano accedere a tutti i contenuti offrendo un'esperienza utente fluida.\"}<\/p><h2 class=\"wp-block-heading\">Il punto fondamentale<\/h2><p class=\"wp-block-paragraph\">Pagination is essential for WordPress sites with multiple pages of content. Use the built-in pagination functions for the main query, handle pagination explicitly in custom queries, paginate comments for long discussion threads, and consider AJAX infinite scroll for a modern user experience. Always ensure paginated content is accessible to search engines through proper rel attributes and progressive enhancement.<\/p>","protected":false},"excerpt":{"rendered":"<p>How to implement pagination in WordPress for posts, comments, and custom queries, from basic pagination to AJAX-powered infinite scroll.<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ai_primary_source":"","visibility_scope":"","ai_summary":"","ai_intent":"","ai_related_resources":"","ai_priority":0,"ai_entity_type":"","ai_is_based_on":"","ai_citations":"","ai_mentions":"","ai_speakable_selector":"","ai_chunk_hints":"","footnotes":""},"categories":[7,6],"tags":[44,27,35],"ai_visibility":[],"class_list":["post-604","post","type-post","status-publish","format-standard","hentry","category-web-development","category-wordpress","tag-api-first","tag-developer-to-founder","tag-saas"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/aarkly.com\/it\/wp-json\/wp\/v2\/posts\/604","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aarkly.com\/it\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aarkly.com\/it\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aarkly.com\/it\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/aarkly.com\/it\/wp-json\/wp\/v2\/comments?post=604"}],"version-history":[{"count":1,"href":"https:\/\/aarkly.com\/it\/wp-json\/wp\/v2\/posts\/604\/revisions"}],"predecessor-version":[{"id":819,"href":"https:\/\/aarkly.com\/it\/wp-json\/wp\/v2\/posts\/604\/revisions\/819"}],"wp:attachment":[{"href":"https:\/\/aarkly.com\/it\/wp-json\/wp\/v2\/media?parent=604"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aarkly.com\/it\/wp-json\/wp\/v2\/categories?post=604"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aarkly.com\/it\/wp-json\/wp\/v2\/tags?post=604"},{"taxonomy":"ai_visibility","embeddable":true,"href":"https:\/\/aarkly.com\/it\/wp-json\/wp\/v2\/ai_visibility?post=604"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}