Skip to content

Instantly share code, notes, and snippets.

@kibria-khandaker
Created August 26, 2019 09:13
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 kibria-khandaker/847d7cb7c8ddd9cfe8905dc7057c0924 to your computer and use it in GitHub Desktop.
Save kibria-khandaker/847d7cb7c8ddd9cfe8905dc7057c0924 to your computer and use it in GitHub Desktop.
1) ***jekhane Button lagbe **
<!-- Load More Btn start HTML xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -->
<div class="row">
<div class="col-12 text-center" id="loadmore-container">
<a href="<?php // next_posts(get_max_num_pages()); ?>" class="btn btn-danger" id="loadmore">
<?php // _e('Load More', 'textdomain'); ?>
</a>
</div>
</div>
<!-- Load More Btn End HTML xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -->
## id="posts-container" ta ke rakte hobe container row er por je div er vitore while (have_posts()) er post likha hoyeche ,orthat poser div e
2) function PHP er vitor ei code tuku lagbe
// Load More Btn start php
function get_max_num_pages(){
global $wp_query;
return $wp_query->max_num_pages;
}
// Load More Btn end php
3) Js er jomnno
// Load More Btn start js xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx// jodi new file thake ;(function($){
$(document).ready(function(){
$("#loadmore").on('click', function(e){
var nexturl = $(this).attr('href');
$.get(nexturl,{},function(data){
var posts = $(data).find("#posts-container").html();
$("#posts-container").append(posts);
var newpagelink = $(data).find("#loadmore").attr('href');
if(newpagelink){
$("#loadmore").attr('href', newpagelink);
}
else{
$("#loadmore").hide('slow');
}
});
return false;
});
var newpagelink = $("#loadmore").attr('href');
if(!newpagelink){
$("#loadmore").hide();
}
});
// Load More Btn end js xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx // jodi new file thake })(jQuery);
https://www.helalwp.com/code/?s=load+more
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment