Instantly share code, notes, and snippets.

@raiden808 raiden808/blog_3 part 2 Secret
Created Jan 22, 2019

Embed
What would you like to do?
add_action('wp_head',function(){
?>
<script type="text/javascript">
jQuery(document).ready(function( $ ) {
var ajaxUrl = "<?php echo admin_url('admin-ajax.php')?>";
var page = 1; // What page we are on.
var ppp = 3; // Post per page
$("#more_posts").on("click",function(e){ // When btn is pressed.
e.preventDefault();
$("#more_posts").attr("disabled",true); // Disable the button, temp.
$.post(ajaxUrl, {
action:"more_post_ajax",
offset: (page * ppp) + 1,
ppp: ppp
}).success(function(posts){
page++;
$(".blog_wrapper").append(posts); // CHANGE THIS!
$("#more_posts").attr("disabled",false);
});
});
});
</script>
<?php
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment