Guest User

Untitled

a guest
Oct 18th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.68 KB | None | 0 0
  1. <?php get_header(); ?>
  2.  
  3.  
  4.  
  5. <div id="load_posts_container">
  6.  
  7.  
  8.  
  9. <?php
  10.  
  11. $category_ID = get_category_id('blog');
  12.  
  13. $args = array(
  14.  
  15. 'post_type' => 'post',
  16.  
  17. 'posts_per_page' => 12,
  18.  
  19. 'cat' => '-' . $category_ID,
  20.  
  21. 'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1)
  22.  
  23. );
  24.  
  25. query_posts($args);
  26.  
  27. $x = 0;
  28.  
  29.  
  30.  
  31. $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
  32.  
  33. if($paged > 1)
  34.  
  35. $y = (0 + (($paged-1) * 12));
  36.  
  37. else
  38.  
  39. $y = 0;
  40.  
  41. while (have_posts()) : the_post(); ?>
  42.  
  43.  
  44.  
  45. <?php if($x == 2) { ?>
  46.  
  47.  
  48. <div class="home_post_box home_post_box_last" onmouseover="show_post_desc(<?php echo $y; ?>)" onmouseout="hide_post_desc(<?php echo $y; ?>)">
  49.  
  50.  
  51. <?php } else { ?>
  52.  
  53. <div class="home_post_box" onmouseover="show_post_desc(<?php echo $y; ?>)" onmouseout="hide_post_desc(<?php echo $y; ?>)">
  54.  
  55. <?php } ?>
  56.  
  57.  
  58.  
  59. <!--<img src="<?php bloginfo('stylesheet_directory'); ?>/images/blog-image.jpg" />-->
  60.  
  61. <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('home-post',array('alt' => 'post image', 'class' => 'rounded')); ?></a>
  62.  
  63.  
  64.  
  65. <div class="home_post_desc" id="home_post_desc<?php echo $y; ?>">
  66.  
  67. <?php $temp_arr_content = explode(" ",substr(strip_tags(get_the_content()),0,222)); $temp_arr_content[count($temp_arr_content)-1] = ""; $display_arr_content = implode(" ",$temp_arr_content); echo $display_arr_content . '...'; ?>
  68.  
  69. </div><!--//home_post_desc-->
  70.  
  71.  
  72.  
  73. <div class="home_post_title_cont">
  74.  
  75. <h3><?php the_title(); ?></h3>
  76.  
  77. <h4><?php the_category(', '); ?></h4>
  78.  
  79. </div><!--//home_post_title_cont-->
  80.  
  81. </div><!--//home_post_box-->
  82.  
  83.  
  84.  
  85. <?php if($x == 2) { $x = -1; /*echo '<div class="clear"></div>';*/ } ?>
  86.  
  87.  
  88.  
  89. <?php $x++; $y++; ?>
  90.  
  91. <?php endwhile; ?>
  92.  
  93. <?php wp_reset_query(); ?>
  94.  
  95.  
  96.  
  97. <div class="clear"></div>
  98.  
  99.  
  100.  
  101. </div><!--//load_posts_container-->
  102.  
  103.  
  104.  
  105. <div class="load_more_cont">
  106.  
  107. <p align="center"><span class="load_more_text"><?php next_posts_link('<img src="' . get_bloginfo('stylesheet_directory') . '/images/load-more-image.png" />') ?></span></p>
  108.  
  109. </div><!--//load_more_cont-->
  110.  
  111.  
  112.  
  113.  
  114.  
  115. <script type="text/javascript">
  116.  
  117. // Ajax-fetching "Load more posts"
  118.  
  119. $('.load_more_cont a').live('click', function(e) {
  120.  
  121. e.preventDefault();
  122.  
  123. //$(this).addClass('loading').text('Loading...');
  124.  
  125. //$('.load_more_text a').html('Loading...');
  126.  
  127. $.ajax({
  128.  
  129. type: "GET",
  130.  
  131. url: $(this).attr('href') + '#main_container',
  132.  
  133. dataType: "html",
  134.  
  135. success: function(out) {
  136.  
  137. result = $(out).find('#load_posts_container .home_post_box');
  138.  
  139. nextlink = $(out).find('.load_more_cont a').attr('href');
  140.  
  141. //alert(nextlink);
  142.  
  143. //$('#boxes').append(result).masonry('appended', result);
  144.  
  145. $('#load_posts_container').append(result);
  146.  
  147. //$('.fetch a').removeClass('loading').text('Load more posts');
  148.  
  149. //$('.load_more_text a').html('Load More');
  150.  
  151.  
  152.  
  153.  
  154.  
  155. if (nextlink != undefined) {
  156.  
  157. $('.load_more_cont a').attr('href', nextlink);
  158.  
  159. } else {
  160.  
  161. $('.load_more_cont').remove();
  162.  
  163. $('#load_posts_container').append('<div class="clear"></div>');
  164.  
  165. // $('.load_more_cont').css('visibilty','hidden');
  166.  
  167. }
  168.  
  169.  
  170.  
  171. if (nextlink != undefined) {
  172.  
  173. $.get(nextlink, function(data) {
  174.  
  175. //alert(nextlink);
  176.  
  177. if($(data + ":contains('home_post_box')") != '') {
  178.  
  179. //alert('not found');
  180.  
  181. // $('.load_more_cont').remove();
  182.  
  183. $('#load_posts_container').append('<div class="clear"></div>');
  184.  
  185. }
  186.  
  187. });
  188.  
  189. }
  190.  
  191.  
  192.  
  193. }
  194.  
  195. });
  196.  
  197. });
  198.  
  199. </script>
  200.  
  201.  
  202.  
  203. <?php get_footer(); ?>
Add Comment
Please, Sign In to add comment