Skip to content

Instantly share code, notes, and snippets.

@raiden808
Created January 22, 2019 07:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raiden808/cbee1ad87ce668e225b6fe7555956e79 to your computer and use it in GitHub Desktop.
Save raiden808/cbee1ad87ce668e225b6fe7555956e79 to your computer and use it in GitHub Desktop.
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