Skip to content

Instantly share code, notes, and snippets.

@mgibbs189
Last active August 19, 2016 21:12
Show Gist options
  • Save mgibbs189/33fa89e2997f14ac15239ec6a1d0d886 to your computer and use it in GitHub Desktop.
Save mgibbs189/33fa89e2997f14ac15239ec6a1d0d886 to your computer and use it in GitHub Desktop.
FacetWP - intercept Genesis pagination
(function($) {
$(document).on('click', '.pagination a', function(e) {
e.preventDefault();
var matches = $(this).attr('href').match(/\/page\/(\d+)/);
if (null != matches) {
FWP.paged = parseInt(matches[1]);
}
FWP.soft_refresh = true;
FWP.refresh();
});
})(jQuery);
@JiveDig
Copy link

JiveDig commented Aug 18, 2016

Great snippet, this worked right away. It was strangely leaving my screen at the bottom of the page so I added $('html, body').animate({ scrollTop: 0 }, 'slow');. Still slightly awkward, but working. Thanks for this.

@robneu
Copy link

robneu commented Aug 19, 2016

FYI, this breaks the next/previous post links in the Genesis pagination. I dug through a bit and it seems to be due to the fact that they use get_previous_posts_link and get_next_posts_link for their next and prev links rather than paginate_links like the pagination function in core uses.

I messed around with it a little and ended up ditching the Genesis pagination in favor of what's in core, which still works with this and is better in general anyway IMO.

I also ran into the same thing as Mike and handled it by adding scroll( 0, 0 ); after the refresh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment