Skip to content

Instantly share code, notes, and snippets.

@PhongGCS
Last active October 26, 2021 08:15
Show Gist options
  • Save PhongGCS/178fbcb40b6e926718129b072ec6bf03 to your computer and use it in GitHub Desktop.
Save PhongGCS/178fbcb40b6e926718129b072ec6bf03 to your computer and use it in GitHub Desktop.
Pagination ajax for wordpress
function pagination(url) {
let html = jQuery.get(url)
html.done( (res) => {
let elements = jQuery(res);
let found = jQuery('#main', elements);
let child = found.children();
jQuery('#main').empty();
jQuery('#main').append(child)
});
}
jQuery("a.page-number").on("click", (event) => {
event.preventDefault();
let target = event.target;
url = jQuery(target).attr("href");
pagination(url)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment