SHARE
TWEET

Untitled

a guest Dec 15th, 2018 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ////load more btn for blog pages ||  active on active js or main js////
  2. ;(function($){
  3.     $(document).ready(function(){
  4.         $("#loadmore").on('click', function(e){
  5.             var nexturl = $(this).attr('href');
  6.             $.get(nexturl,{},function(data){
  7.                 var posts = $(data).find("#posts-container").html();
  8.                 $("#posts-container").append(posts);
  9.  
  10.                 var newpagelink = $(data).find("#loadmore").attr('href');
  11.                 if(newpagelink){
  12.                     $("#loadmore").attr('href', newpagelink);
  13.                 }
  14.                 else{
  15.                     $("#loadmore").hide('slow');
  16.                 }
  17.             });
  18.             return false;
  19.         });
  20.  
  21.         var newpagelink = $("#loadmore").attr('href');
  22.         if(!newpagelink){
  23.             $("#loadmore").hide();
  24.         }
  25.  
  26.     });
  27. })(jQuery);
  28. ////load more btn for blog pages ||  active on active js or main js////
  29.  
  30.  
  31.  
  32. /////////////html markup for load more btn ajax///////////////
  33. <div class="row">
  34.     <div class="col-12 text-center" id="loadmore-container">
  35.         <a href="<?php next_posts(get_max_num_pages()); ?>" class="btn btn-danger" id="loadmore">
  36.             <?php _e('Load More', 'textdomain'); ?>
  37.         </a>
  38.     </div>
  39. </div>
  40. /////////////html markup for load more btn ajax///////////////
  41.  
  42.  
  43.  
  44. ////////////add this code to function phs/////////////
  45. function get_max_num_pages(){
  46.     global $wp_query;
  47.     return $wp_query->max_num_pages;
  48. }
  49. ////////////add this code to function phs/////////////
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top