{"id":4173,"date":"2022-08-21T21:30:47","date_gmt":"2022-08-21T16:00:47","guid":{"rendered":"https:\/\/jassweb.com\/solved\/solved-how-to-fix-pagination-for-custom-loops\/"},"modified":"2022-08-21T21:30:47","modified_gmt":"2022-08-21T16:00:47","slug":"solved-how-to-fix-pagination-for-custom-loops","status":"publish","type":"post","link":"https:\/\/jassweb.com\/solved\/solved-how-to-fix-pagination-for-custom-loops\/","title":{"rendered":"[Solved] How to fix pagination for custom loops?"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div id=\"answer-120408\" class=\"answer js-answer accepted-answer js-accepted-answer\" data-answerid=\"120408\" data-parentid=\"120407\" data-score=\"241\" data-position-on-page=\"1\" data-highest-scored=\"1\" data-question-has-accepted-highest-score=\"1\" itemprop=\"suggestedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<div class=\"post-layout\">\n<div class=\"votecell post-layout--left\"><\/div>\n<div class=\"answercell post-layout--right\">\n<div class=\"s-prose js-post-body\" itemprop=\"text\">\n<h1>The Problem<\/h1>\n<p>By default, in any given context, WordPress uses the main query to determine pagination. The main query object is stored in the <code>$wp_query<\/code> global, which is also used to output the main query loop:<\/p>\n<pre><code>if ( have_posts() ) : while ( have_posts() ) : the_post();\n<\/code><\/pre>\n<p>When you <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/codex.wordpress.org\/Class_Reference\/WP_Query\">use a custom query<\/a>, you create an entirely separate query object:<\/p>\n<pre><code>$custom_query = new WP_Query( $custom_query_args );\n<\/code><\/pre>\n<p>And that query is output via an entirely separate loop:<\/p>\n<pre><code>if ( $custom_query-&gt;have_posts() ) : \n    while ( $custom_query-&gt;have_posts() ) : \n        $custom_query-&gt;the_post();\n<\/code><\/pre>\n<p>But pagination template tags, including <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/codex.wordpress.org\/Function_Reference\/previous_posts_link\"><code>previous_posts_link()<\/code><\/a>, <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/codex.wordpress.org\/Function_Reference\/next_posts_link\"><code>next_posts_link()<\/code><\/a>, <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/codex.wordpress.org\/Function_Reference\/posts_nav_link\"><code>posts_nav_link()<\/code><\/a>, and <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/codex.wordpress.org\/Function_Reference\/paginate_links\"><code>paginate_links()<\/code><\/a>, base their output on the <em>main query object<\/em>, <code>$wp_query<\/code>. That main query may or may not be paginated. If the current context is a custom page template, for example, the main <code>$wp_query<\/code> object will consist of only a <em>single post<\/em> &#8211; that of the ID of the page to which the custom page template is assigned. <\/p>\n<p>If the current context is an archive index of some sort, the main <code>$wp_query<\/code> may consist of enough posts to cause pagination, which leads to the next part of the problem:  for the main <code>$wp_query<\/code> object, WordPress will pass a <code>paged<\/code>  parameter to the query, based on the <code>paged<\/code> URL query variable. When the query is fetched, that <code>paged<\/code> parameter will be used to determine which set of paginated posts to return. If a displayed pagination link is clicked, and the next page loaded, <em>your custom query won&#8217;t have any way to know that the pagination has changed<\/em>.<\/p>\n<h1>The Solution<\/h1>\n<h2>Passing Correct Paged Parameter to the Custom Query<\/h2>\n<p>Assuming that the custom query uses an args array:<\/p>\n<pre><code>$custom_query_args = array(\n    \/\/ Custom query parameters go here\n);\n<\/code><\/pre>\n<p>You will need to pass the correct <code>paged<\/code> parameter to the array. You can do so by fetching the URL query variable used to determine the current page, via <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/codex.wordpress.org\/Function_Reference\/get_query_var\"><code>get_query_var()<\/code><\/a>:<\/p>\n<pre><code>get_query_var( 'paged' );\n<\/code><\/pre>\n<p>You can then append that parameter to your custom query args array:<\/p>\n<pre><code>$custom_query_args['paged'] = get_query_var( 'paged' ) \n    ? get_query_var( 'paged' ) \n    : 1;\n<\/code><\/pre>\n<p><strong>Note:<\/strong> If your page is a <strong>static front page<\/strong>, be sure to use <code>page<\/code> instead of <code>paged<\/code> as a static front page uses <code>page<\/code> and not <code>paged<\/code>. This is what you should have for a static front page<\/p>\n<pre><code>$custom_query_args['paged'] = get_query_var( 'page' ) \n    ? get_query_var( 'page' ) \n    : 1;\n<\/code><\/pre>\n<p>Now, when the custom query is fetched, the correct set of paginated posts will be returned.<\/p>\n<h2>Using Custom Query Object for Pagination Functions<\/h2>\n<p>In order for pagination functions to yield the correct output &#8211; i.e. previous\/next\/page links relative to the custom query &#8211; WordPress needs to be forced to recognize the custom query. This requires a bit of a &#8220;hack&#8221;: replacing the main <code>$wp_query<\/code> object with the custom query object, <code>$custom_query<\/code>:<\/p>\n<h3>Hack the main query object<\/h3>\n<ol>\n<li>Backup the main query object: <code>$temp_query = $wp_query<\/code><\/li>\n<li>Null the main query object: <code>$wp_query = NULL;<\/code><\/li>\n<li>\n<p>Swap the custom query into the main query object: <code>$wp_query = $custom_query;<\/code><\/p>\n<pre><code>$temp_query = $wp_query;\n$wp_query   = NULL;\n$wp_query   = $custom_query;\n<\/code><\/pre>\n<\/li>\n<\/ol>\n<p>This &#8220;hack&#8221; must be done <em>before calling any pagination functions<\/em><\/p>\n<h3>Reset the main query object<\/h3>\n<p>Once pagination functions have been output, reset the main query object:<\/p>\n<pre><code>$wp_query = NULL;\n$wp_query = $temp_query;\n<\/code><\/pre>\n<h2>Pagination Function Fixes<\/h2>\n<p>The <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/codex.wordpress.org\/Function_Reference\/previous_posts_link\"><code>previous_posts_link()<\/code><\/a> function will work normally, regardless of pagination. It merely determines the current page, and then outputs the link for <code>page - 1<\/code>. However, a fix is required for <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/codex.wordpress.org\/Function_Reference\/next_posts_link\"><code>next_posts_link()<\/code><\/a> to output properly. This is because <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/codex.wordpress.org\/Function_Reference\/next_posts_link\"><code>next_posts_link()<\/code><\/a> uses the <code>max_num_pages<\/code> parameter:<\/p>\n<pre><code>&lt;?php next_posts_link( $label , $max_pages ); ?&gt;\n<\/code><\/pre>\n<p>As with other query parameters, by default the function will use <code>max_num_pages<\/code> for the main <code>$wp_query<\/code> object. In order to force <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/codex.wordpress.org\/Function_Reference\/next_posts_link\"><code>next_posts_link()<\/code><\/a> to account for the <code>$custom_query<\/code> object, you will need to pass the <code>max_num_pages<\/code> to the function. You can fetch this value from the <code>$custom_query<\/code> object: <code>$custom_query-&gt;max_num_pages<\/code>:<\/p>\n<pre><code>&lt;?php next_posts_link( 'Older Posts' , $custom_query-&gt;max_num_pages ); ?&gt;\n<\/code><\/pre>\n<h1>Putting it all together<\/h1>\n<p>The following is a basic construct of a custom query loop with properly functioning pagination functions:<\/p>\n<pre><code>\/\/ Define custom query parameters\n$custom_query_args = array( \/* Parameters go here *\/ );\n\n\/\/ Get current page and append to custom query parameters array\n$custom_query_args['paged'] = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;\n\n\/\/ Instantiate custom query\n$custom_query = new WP_Query( $custom_query_args );\n\n\/\/ Pagination fix\n$temp_query = $wp_query;\n$wp_query   = NULL;\n$wp_query   = $custom_query;\n\n\/\/ Output custom query loop\nif ( $custom_query-&gt;have_posts() ) :\n    while ( $custom_query-&gt;have_posts() ) :\n        $custom_query-&gt;the_post();\n        \/\/ Loop output goes here\n    endwhile;\nendif;\n\/\/ Reset postdata\nwp_reset_postdata();\n\n\/\/ Custom query loop pagination\nprevious_posts_link( 'Older Posts' );\nnext_posts_link( 'Newer Posts', $custom_query-&gt;max_num_pages );\n\n\/\/ Reset main query object\n$wp_query = NULL;\n$wp_query = $temp_query;\n<\/code><\/pre>\n<h1>Addendum: What About <code>query_posts()<\/code>?<\/h1>\n<h2><code>query_posts()<\/code> for Secondary Loops<\/h2>\n<p>If you&#8217;re using <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/codex.wordpress.org\/Function_Reference\/query_posts\"><code>query_posts()<\/code><\/a> to output a custom loop, rather then instantiating a separate object for the custom query via <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/codex.wordpress.org\/Class_Reference\/WP_Query\"><code>WP_Query()<\/code><\/a>, then you&#8217;re <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/developer.wordpress.org\/reference\/functions\/_doing_it_wrong\/\"><code>_doing_it_wrong()<\/code><\/a>, and will run into several problems (not the <em>least<\/em> of which will be pagination issues). The first step to resolving those issues will be to convert the improper use of <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/codex.wordpress.org\/Function_Reference\/query_posts\"><code>query_posts()<\/code><\/a> to a proper <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/codex.wordpress.org\/Class_Reference\/WP_Query\"><code>WP_Query()<\/code><\/a> call.<\/p>\n<h2>Using <code>query_posts()<\/code> to Modify the Main Loop<\/h2>\n<p>If you merely want to modify the parameters for the <em>main loop query<\/em> &#8211; such as changing the posts per page, or excluding a category &#8211; you may be tempted to use <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/codex.wordpress.org\/Function_Reference\/query_posts\"><code>query_posts()<\/code><\/a>. But you still shouldn&#8217;t. When you use <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/codex.wordpress.org\/Function_Reference\/query_posts\"><code>query_posts()<\/code><\/a>, you force WordPress to <em>replace<\/em> the main query object. (WordPress actually makes a second query, and overwrites <code>$wp_query<\/code>.) The problem, though, is that it does this replacement too late in the process to update the pagination.<\/p>\n<p>The solution is to <em>filter the main query before posts are fetched<\/em>, via the <code>pre_get_posts<\/code> hook.<\/p>\n<p>Instead of adding this to the category template file (<code>category.php<\/code>):<\/p>\n<pre><code>query_posts( array(\n    'posts_per_page' =&gt; 5\n) );\n<\/code><\/pre>\n<p>Add the following to <code>functions.php<\/code>:<\/p>\n<pre><code>function wpse120407_pre_get_posts( $query ) {\n    \/\/ Test for category archive index\n    \/\/ and ensure that the query is the main query\n    \/\/ and not a secondary query (such as a nav menu\n    \/\/ or recent posts widget output, etc.\n    if ( is_category() &amp;&amp; $query-&gt;is_main_query() ) {\n        \/\/ Modify posts per page\n        $query-&gt;set( 'posts_per_page', 5 ); \n    }\n}\nadd_action( 'pre_get_posts', 'wpse120407_pre_get_posts' );\n<\/code><\/pre>\n<p>Instead of adding this to the blog posts index template file (<code>home.php<\/code>):<\/p>\n<pre><code>query_posts( array(\n    'cat' =&gt; '-5'\n) );\n<\/code><\/pre>\n<p>Add the following to <code>functions.php<\/code>:<\/p>\n<pre><code>function wpse120407_pre_get_posts( $query ) {\n    \/\/ Test for main blog posts index\n    \/\/ and ensure that the query is the main query\n    \/\/ and not a secondary query (such as a nav menu\n    \/\/ or recent posts widget output, etc.\n    if ( is_home() &amp;&amp; $query-&gt;is_main_query() ) {\n        \/\/ Exclude category ID 5\n        $query-&gt;set( 'category__not_in', array( 5 ) ); \n    }\n}\nadd_action( 'pre_get_posts', 'wpse120407_pre_get_posts' );\n<\/code><\/pre>\n<p>That way, WordPress will use the already-modified <code>$wp_query<\/code> object when determining pagination, with no template modification required. <\/p>\n<h2>When to use what function<\/h2>\n<p>Research this question and answer and this question and answer to understand how and when to use <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/codex.wordpress.org\/Class_Reference\/WP_Query\"><code>WP_Query<\/code><\/a>, <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/codex.wordpress.org\/Plugin_API\/Action_Reference\/pre_get_posts\"><code>pre_get_posts<\/code><\/a>, and <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/codex.wordpress.org\/Function_Reference\/query_posts\"><code>query_posts()<\/code><\/a>.<\/p>\n<\/p><\/div>\n<div class=\"mt24\"><\/div>\n<\/div>\n<p>            <span class=\"d-none\" itemprop=\"commentCount\">11<\/span> <\/p><\/div>\n<\/div>\n<p>[ad_2]<\/p>\n<p>solved How to fix pagination for custom loops? <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] The Problem By default, in any given context, WordPress uses the main query to determine pagination. The main query object is stored in the $wp_query global, which is also used to output the main query loop: if ( have_posts() ) : while ( have_posts() ) : the_post(); When you use a custom query, you &#8230; <a title=\"[Solved] How to fix pagination for custom loops?\" class=\"read-more\" href=\"https:\/\/jassweb.com\/solved\/solved-how-to-fix-pagination-for-custom-loops\/\" aria-label=\"More on [Solved] How to fix pagination for custom loops?\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[627],"tags":[637,638,630],"class_list":["post-4173","post","type-post","status-publish","format-standard","hentry","category-wordpress","tag-loop","tag-pagination","tag-query"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[Solved] How to fix pagination for custom loops? - JassWeb<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jassweb.com\/solved\/solved-how-to-fix-pagination-for-custom-loops\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Solved] How to fix pagination for custom loops? - JassWeb\" \/>\n<meta property=\"og:description\" content=\"[ad_1] The Problem By default, in any given context, WordPress uses the main query to determine pagination. The main query object is stored in the $wp_query global, which is also used to output the main query loop: if ( have_posts() ) : while ( have_posts() ) : the_post(); When you use a custom query, you ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jassweb.com\/solved\/solved-how-to-fix-pagination-for-custom-loops\/\" \/>\n<meta property=\"og:site_name\" content=\"JassWeb\" \/>\n<meta property=\"article:published_time\" content=\"2022-08-21T16:00:47+00:00\" \/>\n<meta name=\"author\" content=\"Kirat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kirat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-fix-pagination-for-custom-loops\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-fix-pagination-for-custom-loops\/\"},\"author\":{\"name\":\"Kirat\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\"},\"headline\":\"[Solved] How to fix pagination for custom loops?\",\"datePublished\":\"2022-08-21T16:00:47+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-fix-pagination-for-custom-loops\/\"},\"wordCount\":770,\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"keywords\":[\"loop\",\"pagination\",\"query\"],\"articleSection\":[\"WordPress\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-fix-pagination-for-custom-loops\/\",\"url\":\"https:\/\/jassweb.com\/solved\/solved-how-to-fix-pagination-for-custom-loops\/\",\"name\":\"[Solved] How to fix pagination for custom loops? - JassWeb\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#website\"},\"datePublished\":\"2022-08-21T16:00:47+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-fix-pagination-for-custom-loops\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/jassweb.com\/solved\/solved-how-to-fix-pagination-for-custom-loops\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-fix-pagination-for-custom-loops\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/jassweb.com\/solved\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Solved] How to fix pagination for custom loops?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/jassweb.com\/solved\/#website\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"name\":\"JassWeb\",\"description\":\"Build High-quality Websites\",\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/jassweb.com\/solved\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\",\"name\":\"Jass Web\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"contentUrl\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"width\":693,\"height\":132,\"caption\":\"Jass Web\"},\"image\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\",\"name\":\"Kirat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750\",\"contentUrl\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750\",\"caption\":\"Kirat\"},\"sameAs\":[\"http:\/\/jassweb.com\"],\"url\":\"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Solved] How to fix pagination for custom loops? - JassWeb","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jassweb.com\/solved\/solved-how-to-fix-pagination-for-custom-loops\/","og_locale":"en_US","og_type":"article","og_title":"[Solved] How to fix pagination for custom loops? - JassWeb","og_description":"[ad_1] The Problem By default, in any given context, WordPress uses the main query to determine pagination. The main query object is stored in the $wp_query global, which is also used to output the main query loop: if ( have_posts() ) : while ( have_posts() ) : the_post(); When you use a custom query, you ... Read more","og_url":"https:\/\/jassweb.com\/solved\/solved-how-to-fix-pagination-for-custom-loops\/","og_site_name":"JassWeb","article_published_time":"2022-08-21T16:00:47+00:00","author":"Kirat","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kirat","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jassweb.com\/solved\/solved-how-to-fix-pagination-for-custom-loops\/#article","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-to-fix-pagination-for-custom-loops\/"},"author":{"name":"Kirat","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31"},"headline":"[Solved] How to fix pagination for custom loops?","datePublished":"2022-08-21T16:00:47+00:00","mainEntityOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-to-fix-pagination-for-custom-loops\/"},"wordCount":770,"publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"keywords":["loop","pagination","query"],"articleSection":["WordPress"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jassweb.com\/solved\/solved-how-to-fix-pagination-for-custom-loops\/","url":"https:\/\/jassweb.com\/solved\/solved-how-to-fix-pagination-for-custom-loops\/","name":"[Solved] How to fix pagination for custom loops? - JassWeb","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/#website"},"datePublished":"2022-08-21T16:00:47+00:00","breadcrumb":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-to-fix-pagination-for-custom-loops\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jassweb.com\/solved\/solved-how-to-fix-pagination-for-custom-loops\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jassweb.com\/solved\/solved-how-to-fix-pagination-for-custom-loops\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jassweb.com\/solved\/"},{"@type":"ListItem","position":2,"name":"[Solved] How to fix pagination for custom loops?"}]},{"@type":"WebSite","@id":"https:\/\/jassweb.com\/solved\/#website","url":"https:\/\/jassweb.com\/solved\/","name":"JassWeb","description":"Build High-quality Websites","publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jassweb.com\/solved\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/jassweb.com\/solved\/#organization","name":"Jass Web","url":"https:\/\/jassweb.com\/solved\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/","url":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","contentUrl":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","width":693,"height":132,"caption":"Jass Web"},"image":{"@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31","name":"Kirat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/","url":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750","caption":"Kirat"},"sameAs":["http:\/\/jassweb.com"],"url":"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/4173","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/comments?post=4173"}],"version-history":[{"count":0,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/4173\/revisions"}],"wp:attachment":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/media?parent=4173"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/categories?post=4173"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/tags?post=4173"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}