Title: Query Loop pagination behavior with tab + static
Last modified: March 10, 2023

---

# Query Loop pagination behavior with tab + static

 *  Resolved [cgrignon](https://wordpress.org/support/users/cgrignon/)
 * (@cgrignon)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/query-loop-pagination-behavior-with-tab-static/)
 * Hi there,
 * I have a news page where I have a tab (using the Tab block from Kadence Blocks)
   for each post category. Then for each tab, there is a Query Loop from GB. When
   the user clicks on page 2 of a query loop in tab 2 or tab 3, 4… the news page
   goes back to tab 1. 
   I’ve read somewhere that GB intends to add ajax pagination
   soon, however this will not be useful for me as I’m using Strattic hosting (static
   wordpress). Is there a way to tell the query loop to stay on the current tab?
   through an anchor link of the tab or something? The Strattic support told me 
   you might be able to set up different URLs for different tabs. “if they retain
   the page numbers in the URL, it should work fine with Strattic.”Let me know if
   you think it’s possible or if I should look into another way of displaying the
   content.
 * Thanks!
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fquery-loop-pagination-behavior-with-tab-static%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 13 replies - 1 through 13 (of 13 total)

 *  Plugin Support [ying](https://wordpress.org/support/users/yingscarlett/)
 * (@yingscarlett)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/query-loop-pagination-behavior-with-tab-static/#post-16548659)
 * Hi [@cgrignon](https://wordpress.org/support/users/cgrignon/) ,
 * You can try the solution below, but it won’t work for the page number button,
   it will only work for the previous/next button.
    1. Add an HTML anchor to the Kadence tab content container, eg. `case-study`, `
       press-release` , etc. (Not sure if this step would work with the Kadence tab
       block, you might need to check with their support).
    2. Add the CSS class to the **previous** and **next** buttons of the query loop
       block, eg.`case-study-pagination`for the case study section, **press-release-
       pagination** for the press release section and so on.
    3. Add this PHP code:
 *     ```wp-block-code
       add_filter('generateblocks_dynamic_url_output','custom_query_loop_pagination', 10,2);
       function custom_query_loop_pagination($url , $attributes) {
       	if( ! empty( $url ) && ! empty( $attributes['className'] ) &&  'case-study-pagination'  === $attributes['className'] )  {
       		$url = $url.'/#case-study'; 
       	}
               if( ! empty( $url ) && ! empty( $attributes['className'] ) &&  'press-release-pagination'  === $attributes['className'] )  {
       		$url = $url.'/#press-release'; 
       	}
       	if( ! empty( $url ) && ! empty( $attributes['className'] ) &&  'blog-pagination'  === $attributes['className'] )  {
       		$url = $url.'/#blog'; 
       	}
               if( ! empty( $url ) && ! empty( $attributes['className'] ) &&  'all-pagination'  === $attributes['className'] )  {
       		$url = $url.'/#all'; 
       	}
       	return $url;
       }
       ```
   
 *  Thread Starter [cgrignon](https://wordpress.org/support/users/cgrignon/)
 * (@cgrignon)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/query-loop-pagination-behavior-with-tab-static/#post-16556690)
 * Hi [@yingscarlett](https://wordpress.org/support/users/yingscarlett/) , thank
   you for your answer!
 * I tried the code and it almost works. I think now the problem is that the pagination
   comes before the tab anchor in the url – see screenshot link (only on my staging
   website at the moment).
 * So at the moment, when i click on the “next” button, I stay on the right tab,
   but stay on the first page of the query loop
 * [https://snipboard.io/b6yig0.jpg](https://snipboard.io/b6yig0.jpg)
   Let me know
   if there is something I can do.Thank you so much,Clemence
 *  Plugin Support [ying](https://wordpress.org/support/users/yingscarlett/)
 * (@yingscarlett)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/query-loop-pagination-behavior-with-tab-static/#post-16559319)
 * Looking at the screenshot of the URL, it looks right, it shows page2 in the URL.
 * Any chance I can see the site with the code implanted?
 * Let me know!
 *  Thread Starter [cgrignon](https://wordpress.org/support/users/cgrignon/)
 * (@cgrignon)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/query-loop-pagination-behavior-with-tab-static/#post-16561759)
 * Hi [@yingscarlett](https://wordpress.org/support/users/yingscarlett/) , I lived
   the changes so you can investigate the issue, thanks!
 *  Plugin Support [ying](https://wordpress.org/support/users/yingscarlett/)
 * (@yingscarlett)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/query-loop-pagination-behavior-with-tab-static/#post-16563324)
 * The query loop pagination doesn’t seem to be working at all, if you disable the
   PHP code, does the pagination work?
 * I just tested the same method using GB’s tab block and it works perfectly.
 * Let me know!
 *  Thread Starter [cgrignon](https://wordpress.org/support/users/cgrignon/)
 * (@cgrignon)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/query-loop-pagination-behavior-with-tab-static/#post-16565345)
 * Hmm indeed you are right, I didn’t see that. Do you know what may be causing 
   this issue?
 *  Plugin Support [ying](https://wordpress.org/support/users/yingscarlett/)
 * (@yingscarlett)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/query-loop-pagination-behavior-with-tab-static/#post-16567135)
 * I’m not sure, it might be code conflicts between the tabs and the query loop 
   block.
 *  Thread Starter [cgrignon](https://wordpress.org/support/users/cgrignon/)
 * (@cgrignon)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/query-loop-pagination-behavior-with-tab-static/#post-16568657)
 * Oh, then can GenerateBlock look into this? I’ll contact Kadence Block regarding
   this issue as well.
 *  Thread Starter [cgrignon](https://wordpress.org/support/users/cgrignon/)
 * (@cgrignon)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/query-loop-pagination-behavior-with-tab-static/#post-16604546)
 * Hi [@yingscarlett](https://wordpress.org/support/users/yingscarlett/) , I did
   some debugging on my staging and the issue still happens after deactivating all
   plugins but GenerateBlocks. 
   Could it be a conflict with Strattic itself?Best
 *  Plugin Support [David](https://wordpress.org/support/users/diggeddy/)
 * (@diggeddy)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/query-loop-pagination-behavior-with-tab-static/#post-16605891)
 * Hi there,
 * paginated Query Loop blocks on a static page rely on URL query strings to update
   the content. They don’t use `/page/2` URLs as a static page does not support 
   that kind of pagination, and you would not be able to add multiple paginated 
   query loops on the same page if that were the case.
 * And its the same system that WPs core Query Loop block uses. So you can test 
   a core query loop block to see if it has the same issue.
 * If it does it is probably related to your server if its serving static pages 
   you may need to check with them how to handle this.
 *  Thread Starter [cgrignon](https://wordpress.org/support/users/cgrignon/)
 * (@cgrignon)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/query-loop-pagination-behavior-with-tab-static/#post-16608410)
 * Hi David, 
   Thank you so much for your answer. Indeed I just tested with the WP
   Query loop block and it’s the same problem. Let me contact Strattic support then.
   Cheers
 *  Plugin Support [David](https://wordpress.org/support/users/diggeddy/)
 * (@diggeddy)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/query-loop-pagination-behavior-with-tab-static/#post-16610120)
 * You’re welcome
 *  [fernandoazarcon2](https://wordpress.org/support/users/fernandoazarcon2/)
 * (@fernandoazarcon2)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/query-loop-pagination-behavior-with-tab-static/#post-16651283)
 * Hi there! We haven’t heard back from you for a while now so we’re going to go
   ahead and set this topic as resolved. Feel free to reply if you need any more
   help.

Viewing 13 replies - 1 through 13 (of 13 total)

The topic ‘Query Loop pagination behavior with tab + static’ is closed to new replies.

 * ![](https://ps.w.org/generateblocks/assets/icon.svg?rev=3239461)
 * [GenerateBlocks](https://wordpress.org/plugins/generateblocks/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/generateblocks/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/generateblocks/)
 * [Active Topics](https://wordpress.org/support/plugin/generateblocks/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/generateblocks/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/generateblocks/reviews/)

 * 13 replies
 * 4 participants
 * Last reply from: [fernandoazarcon2](https://wordpress.org/support/users/fernandoazarcon2/)
 * Last activity: [3 years, 4 months ago](https://wordpress.org/support/topic/query-loop-pagination-behavior-with-tab-static/#post-16651283)
 * Status: resolved