Site logo

[Support request] Pagination jumps to top of page

Home Forums Support [Support request] Pagination jumps to top of page

Home Forums Support Pagination jumps to top of page

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2502288
    Chris

    I have a static (home) page with a query loop below other content.

    Of course, if someone increments the query loop, they jump to the top of the page and have to scroll down to get to the query loop section. It’s an awkward experience.

    I found one post where Tom mentioned a bit of code that would return the user to the same spot on the page and that it might be included in a future version of GP.

    Has that been added at this point?

    Another potential solution would be a ‘load more’ button that would load additional posts via ajax, I think Show Posts used to do this? Is that possible with GP? (and if so, is it crawlable by search engines?),

    Chris

    #2502634
    David
    Staff
    Customer Support

    Hi there,

    where can i see the issue ? Can you share a link ?

    #2503357
    Chris

    Is this not the standard/expected behavior?

    https://rev.press

    #2503522
    Ying
    Staff
    Customer Support

    It’s expected behaviour. There’s a way to add an ID to the pagenation button’s URL, but it will only work for the previous/next button, not the numbers.

    The steps:

    1. Add an HTML anchor to the grid block nested in the query loop block, eg. my-query.

    2. Add additional CSS class to the previous/next button, eg.pagination-button.

    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'] ) &&  'pagination-button'  === $attributes['className'] )  {
    		$url = $url.'/#my-query'; 
    	}
    	return $url;
    }
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.