• Resolved cgrignon

    (@cgrignon)


    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 to see the link]

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Support ying

    (@yingscarlett)

    Hi @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-paginationfor the case study section, press-release-pagination for the press release section and so on.
    3. Add this PHP 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

    (@cgrignon)

    Hi @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

    Let me know if there is something I can do.
    Thank you so much,
    Clemence

    Plugin Support ying

    (@yingscarlett)

    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

    (@cgrignon)

    Hi @yingscarlett , I lived the changes so you can investigate the issue, thanks!

    Plugin Support ying

    (@yingscarlett)

    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

    (@cgrignon)

    Hmm indeed you are right, I didn’t see that. Do you know what may be causing this issue?

    Plugin Support ying

    (@yingscarlett)

    I’m not sure, it might be code conflicts between the tabs and the query loop block.

    Thread Starter cgrignon

    (@cgrignon)

    Oh, then can GenerateBlock look into this? I’ll contact Kadence Block regarding this issue as well.

    Thread Starter cgrignon

    (@cgrignon)

    Hi @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

    (@diggeddy)

    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

    (@cgrignon)

    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

    (@diggeddy)

    You’re welcome

    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.