RtThemesSupport

home_content_loop.php rt17

Jan 29th, 2013
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.11 KB | None | 0 0
  1. <?php
  2. /*
  3. * rt-theme home page content loop
  4. */
  5.  
  6. global $home_page,$which_theme,$row,$layout_values,$layout,$firstBox,$lastBox,$reset,$this_column_width_pixel,$item_width,$box_border,$layout_values,$content_width,$container_border;
  7.  
  8.  
  9. //keep posts
  10. $keep = new WP_Query($home_page);
  11.  
  12. $count_home_boxes=1;
  13.  
  14. #
  15. # Reset counter for all content listing option
  16. #
  17. $reset_counter = ($item_width) ? 1 : false;
  18.  
  19.  
  20. #
  21. # this column width - pixel - for all content listing option
  22. #
  23. $this_column_width_pixel = ($item_width!=1) ? intval ($this_column_width_pixel/$item_width) : $this_column_width_pixel;
  24.  
  25.  
  26. if ($keep -> have_posts() ) : while ( $keep -> have_posts() ) : $keep -> the_post();
  27.  
  28. #
  29. # Values
  30. #
  31.  
  32. $box_title = get_the_title();
  33. $box_sub_title = get_post_meta($keep->post->ID, THEMESLUG.'sub_title', true);
  34. $custom_link = get_post_meta($keep->post->ID, THEMESLUG.'custom_link', true);
  35. $custom_link_text = get_post_meta($keep->post->ID, THEMESLUG.'custom_link_text', true);
  36. $custom_link_target = get_post_meta($keep->post->ID, THEMESLUG.'custom_link_target', true);
  37. $image = get_post_thumbnail_id();
  38. $crop = get_post_meta($keep->post->ID, THEMESLUG.'homepage_image_crop', true);
  39. $custom_image_height = get_post_meta($keep->post->ID, THEMESLUG.'homepage_image_height', true);
  40. $featured_image_position = @get_post_meta($keep->post->ID, THEMESLUG.'featured_image_position', true);
  41. $heading_and_text_position = @get_post_meta($keep->post->ID, THEMESLUG.'heading_and_text_position', true);
  42. $hide_the_heading = @get_post_meta($keep->post->ID, THEMESLUG.'hide_the_heading', true);
  43.  
  44.  
  45.  
  46. #
  47. # Layout names
  48. #
  49. $layout_names = array("5"=>"five","4"=>"four","3"=>"three","2"=>"two","1"=>"one");
  50.  
  51. #
  52. # Thumbnail dimensions
  53. #
  54. /*
  55. $w = intval ($this_column_width_pixel-40);
  56. $h = intval ($this_column_width_pixel/2);
  57. */
  58.  
  59. $w = ($item_width == 1) ? 940 : (($item_width == 2) ? 440 : 420);
  60. $h = intval($w * 0.6);
  61.  
  62. #
  63. # Crop
  64. #
  65. if($crop) $h=intval($custom_image_height); else $h=10000;
  66.  
  67. #
  68. # Resize Image
  69. #
  70. if($image) $image_thumb = vt_resize( $image, '', $w, $h, $crop );
  71.  
  72.  
  73. #
  74. # Box border
  75. #
  76. $addClass2 = ($box_border) ? "" : "" ;
  77.  
  78. // fixed row holder
  79. if($reset_counter ==1) echo '<div class="fixed-row">';
  80.  
  81. #
  82. # Box Size
  83. #
  84. $layout = ($item_width) ? $layout_names[$item_width] : $layout;
  85. $firstBox = ($reset_counter == 1) ? "first" : false;
  86. $lastBox = ($reset_counter == $item_width) ? "last" : false;
  87. ?>
  88.  
  89. <!-- box -->
  90. <div class="template_builder box home-content-box box-shadow <?php echo $layout;?> <?php echo $firstBox .' '. $lastBox .' '. $addClass2;?>" id="post-<?php echo $keep->post->ID;?>">
  91.  
  92. <?php
  93. //featured image alignments
  94. $thePositionClass = ($featured_image_position) ? explode("-",$featured_image_position): "";
  95. $thePositionClass = $thePositionClass ? "align".$thePositionClass[1] : "";
  96. ?>
  97.  
  98. <?php if($image && ($featured_image_position=="before-center" || $featured_image_position=="before-left" || $featured_image_position=="before-right") ):?>
  99. <?php if ($custom_link) echo "<a href=\"". $custom_link ."\" target=\"".$custom_link_target."\" title=\"". $box_title ."\" >"; ?>
  100. <!-- featured image -->
  101. <img src="<?php echo @$image_thumb["url"];?>" class="featured <?php echo $thePositionClass;?>" alt="<?php echo $box_title;?>" />
  102. <?php if($thePositionClass=="aligncenter" || $thePositionClass==""):?><div class="space margin-b10"></div><?php endif;?>
  103. <?php if ($custom_link) echo "</a>"; ?>
  104. <?php endif;?>
  105.  
  106.  
  107. <?php if($box_title && !$hide_the_heading):?>
  108. <!-- box title-->
  109. <h3 <?php if ($heading_and_text_position=="center") echo 'class="aligncenter"'; ?>><?php if($custom_link):?><a href="<?php echo $custom_link;?>" target="<?php echo $custom_link_target;?>" title="<?php echo $box_title;?>"><?php endif;?><?php echo $box_title;?><?php if($custom_link):?></a><?php endif;?></h3>
  110. <?php endif;?>
  111.  
  112. <?php if($box_title || $box_sub_title):?>
  113. <?php if($thePositionClass=="aligncenter" || $thePositionClass==""):?><div class="space margin-b10"></div><?php endif;?>
  114. <?php endif;?>
  115.  
  116. <?php if($image && ($featured_image_position=="after-center" || $featured_image_position=="after-left" || $featured_image_position=="after-right" || $featured_image_position=="") ):?>
  117. <?php if ($custom_link) echo "<a href=\"". $custom_link ."\" target=\"".$custom_link_target."\" title=\"". $box_title ."\" >"; ?>
  118. <!-- featured image -->
  119. <img src="<?php echo @$image_thumb["url"];?>" class="featured <?php echo $thePositionClass;?>" alt="<?php echo $box_title;?>" />
  120. <?php if($thePositionClass=="aligncenter" || $thePositionClass==""):?><div class="space margin-b10"></div><?php endif;?>
  121. <?php if ($custom_link) echo "</a>"; ?>
  122. <?php endif;?>
  123.  
  124.  
  125. <?php
  126. if ($custom_link && $custom_link_text):
  127. $read_more = "<a href=\"". $custom_link ."\" target=\"".$custom_link_target."\" title=\"". $box_title ."\" class=\"read_more\">". $custom_link_text ." →</a>";
  128. else:
  129. $read_more ="";
  130. endif;
  131. ?>
  132.  
  133. <!-- text-->
  134. <?php
  135. $theContent = apply_filters('the_content',(get_the_content().$read_more));
  136. $theContent = ($heading_and_text_position=="center") ? str_replace("<p","<p class=\"aligncenter\"",$theContent ): $theContent;
  137. echo $theContent;
  138. ?>
  139.  
  140. </div>
  141. <!-- /box -->
  142.  
  143. <?php
  144. #
  145. # Reset columns - for all content listing option
  146. #
  147. $post_count = $keep->post_count;
  148. $margin = 30 ;
  149. //end fixed rows
  150. if (($reset_counter && $item_width==$reset_counter) || $count_home_boxes == $post_count) echo '</div>';
  151.  
  152.  
  153. if ($reset_counter && $item_width==$reset_counter && $count_home_boxes != $post_count):
  154. echo '<div class="clear"></div><div class="space margin-b'.$margin.'"></div>';
  155. $reset_counter=1;
  156. else:
  157. $reset_counter++;
  158. endif;
  159.  
  160. $count_home_boxes ++;
  161. ?>
  162.  
  163. <?php endwhile;endif;?>
  164.  
  165. <?php
  166. $keep = "";
  167. wp_reset_query();?>
Advertisement
Add Comment
Please, Sign In to add comment