Advertisement
Guest User

Untitled

a guest
Apr 4th, 2012
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.73 KB | None | 0 0
  1. <?php
  2. /**
  3. * Posts Loop
  4. *
  5. * This file is responsible for outputting the
  6. * blog posts as well as filter options (if
  7. * the user is viewing the frontpage).
  8. *
  9. * In the event that the html needs to be modified,
  10. * this template may be duplicated inside a child theme
  11. * and edited there.
  12. *
  13. * @package Shaken Grid (Premium)
  14. * @since 1.0
  15. * @alter 2.0
  16. *
  17. ***************************************************************
  18. ***************************************************************
  19. *
  20. * Post Filters
  21. *
  22. * Displays filter options if on frontpage and if they aren't
  23. * disabled in the theme options. The filters are based on
  24. * the categories. Each post has its category slug assigned
  25. * as class names. The Isotope plugin handles the filtering.
  26. */ ?>
  27.  
  28. <?php if(is_home() && !of_get_option('hide_filters')) { ?>
  29. <div id="filtering-nav">
  30. <a href="#" class="filter-btn"><span><?php _e('Filter', 'shaken'); ?></span></a>
  31. <ul>
  32. <li><a href="#" data-filter="*"><?php _e('All', 'shaken'); ?></a></li>
  33. <?php
  34. $args=array(
  35. 'orderby' => 'name',
  36. 'hierarchical' => 0
  37. );
  38. $categories=get_categories($args);
  39. foreach($categories as $category) { ?>
  40. <li><a href="#" data-filter=".<?php echo $category->category_nicename; ?>"><?php echo $category->name; ?></a></li>
  41. <?php } ?>
  42. </ul>
  43. <div class="clearfix"></div>
  44. </div><!-- #filtering-nav -->
  45. <?php } ?>
  46.  
  47. <?php
  48. /**
  49. * Display ALL posts
  50. *
  51. * If this is the homepage and the "show all posts on blog" option
  52. * is checked in the theme options, then display all posts on one
  53. * page without pagination.
  54. */
  55. if( is_home() && !is_search() && ( of_get_option( 'show_all' ) || of_get_option( 'frontpage_category' ) ) ):
  56.  
  57. $query_string = false;
  58.  
  59. if( of_get_option('show_all') ){
  60. $query_string = 'posts_per_page=-1';
  61. }
  62.  
  63. if( of_get_option('frontpage_category') && of_get_option('frontpage_category') != 'all' ){
  64.  
  65. if(of_get_option('show_all')){
  66. $query_string .= '&';
  67. }
  68.  
  69. $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
  70. $query_string .= 'cat='.of_get_option('frontpage_category').'&paged='.$paged;
  71. }
  72.  
  73. if( $query_string ){
  74. query_posts($query_string);
  75. }
  76.  
  77. endif;
  78.  
  79. /* Say hello to the Loop... */
  80. if ( have_posts() ) :
  81.  
  82. /* Anything placed in #sort is positioned by jQuery Masonry */ ?>
  83. <div class="sort">
  84.  
  85. <?php // Display sidebar if it has widgets assigned to it
  86. if( is_active_sidebar( 'gallery-sidebar' ) ) : ?>
  87. <div class="all box col2" id="gallery-sidebar">
  88. <div class="box-content">
  89. <?php get_sidebar(); ?>
  90. </div>
  91. </div>
  92. <?php endif; ?>
  93.  
  94. <?php // Display ads set in theme options
  95. get_template_part( 'includes/ads'); ?>
  96.  
  97. <?php while ( have_posts() ) : the_post();
  98.  
  99. global $my_size, $force_feat_img, $embed_code, $vid_url;
  100.  
  101. // Gather custom fields
  102. $embed_code = get_post_meta($post->ID, 'soy_vid', true);
  103. $vid_url = get_post_meta($post->ID, 'soy_vid_url', true);
  104. $force_feat_img = get_post_meta($post->ID, 'soy_hide_vid', true);
  105. $show_title = get_post_meta($post->ID, 'soy_show_title', true);
  106. $show_desc = get_post_meta($post->ID, 'soy_show_desc', true);
  107. $box_size = get_post_meta($post->ID, 'soy_box_size', true);
  108.  
  109. if( $box_size == 'Medium (485px)' ){
  110. $my_size = 'col3';
  111. $embed_size = '495';
  112. } else if( $box_size == 'Large (660px)' ){
  113. $my_size = 'col4';
  114. $embed_size = '670';
  115. } else if( $box_size == 'Tiny (135px)' ){
  116. $my_size = 'col1';
  117. $embed_size = '145';
  118. }else{
  119. $my_size = 'col2';
  120. $embed_size = '320';
  121. }
  122.  
  123. /* Check whether content is being displayed
  124. * This determines whether a border should be applied
  125. * above the postmeta section
  126. */
  127. if($show_title != 'No'){
  128. $content_class = 'has-content';
  129. } else if($show_desc != 'No' && $post->post_content){
  130. $content_class = 'has-content';
  131. }else {
  132. $content_class = 'no-content';
  133. }
  134.  
  135. // Assign categories as class names to enable filtering
  136. $category_classes = '';
  137.  
  138. foreach( ( get_the_category() ) as $category ) {
  139. $category_classes .= $category->category_nicename . ' ';
  140. }
  141. ?>
  142.  
  143. <div class="all box <?php echo $category_classes . $my_size; ?>">
  144.  
  145. <div <?php post_class( 'box-content '.$content_class ) ?>>
  146. <?php
  147. // Display video if available
  148. if( ( $embed_code || $vid_url ) && !$force_feat_img ):
  149.  
  150. if( $vid_url ){
  151. echo '<div class="vid-container">'.apply_filters('the_content', '[embed width="' . $embed_size . '"]' . $vid_url . '[/embed]').'</div>';
  152. } else {
  153. echo '<div class="vid-container">'.$embed_code.'</div>';
  154. }
  155.  
  156. // Display gallery
  157. elseif( has_post_format( 'gallery' ) && !$force_feat_img ):
  158.  
  159. get_template_part( 'includes/loop-gallery' );
  160.  
  161. // Display featured image
  162. elseif ( has_post_thumbnail() ): ?>
  163.  
  164. <div class="img-container">
  165. <?php
  166. // Display the appropriate sized featured image
  167. if( $my_size != 'col2' ): ?>
  168. <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail($my_size, array( 'class' => 'feat-img' ) ); ?></a>
  169. <?php else: ?>
  170. <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('post-thumbnail', array( 'class' => 'feat-img' ) ); ?></a>
  171. <?php endif;
  172.  
  173. // Display View/Share/Comment buttons
  174. if( !of_get_option( 'hide_action_buttons' ) ) :
  175. get_template_part( 'includes/action-buttons' );
  176. endif; ?>
  177. </div><!-- #img-container -->
  178.  
  179. <?php if( has_post_format( 'gallery' ) ) get_template_part( 'includes/gallery-list' ); ?>
  180.  
  181. <?php endif; // #has_post_thumbnail() ?>
  182.  
  183. <div class="post-content">
  184.  
  185. <?php // Display post title
  186. if( $show_title != 'No' && !has_post_format('quote') ): ?>
  187. <h2><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" rel="bookmark">
  188. <?php the_title(); ?>
  189. </a></h2>
  190. <?php endif;
  191.  
  192. // Display post content
  193. if( is_search() && $show_desc != 'No' ):
  194.  
  195. the_excerpt(); // Only display excerpts for search results
  196.  
  197. elseif( $show_desc != 'No' ):
  198.  
  199. if( has_excerpt() ){
  200. the_excerpt();
  201. } else{
  202. the_content(__('Continue Reading &rarr;', 'shaken'));
  203. }
  204.  
  205. endif; ?>
  206.  
  207. <?php edit_post_link(__('Edit this post', 'shaken')); ?>
  208. </div><!-- #entry -->
  209.  
  210. <?php // Display post footer
  211. if( $my_size != 'col1' ): ?>
  212. <div class="post-footer">
  213. <span class="category-ic"><?php the_category(', '); ?></span>
  214. <a href="<?php echo wp_get_shortlink(); ?>" class="shortlink tooltip" title="Shortlink"><?php _e('Shortlink', 'shaken'); ?></a>
  215. </div>
  216. <?php endif; ?>
  217.  
  218. </div><!-- #box-content -->
  219. </div><!-- #box -->
  220. <?php endwhile; ?>
  221. </div><!-- #sort -->
  222.  
  223. <?php // Display pagination when applicable
  224. if ( $wp_query->max_num_pages > 1 ) : ?>
  225. <div id="nav-below" class="navigation">
  226. <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older', 'shaken') ); ?></div>
  227. <div class="nav-next"><?php previous_posts_link( __( 'Newer <span class="meta-nav">&rarr;</span>', 'shaken') ); ?></div>
  228. <div class="clearfix"></div>
  229. </div><!-- #nav-below -->
  230. <?php endif; ?>
  231.  
  232. <?php else :
  233. /* If there are no posts */ ?>
  234. <div id="sort">
  235. <div class="box">
  236. <h2><?php _e('Sorry, no posts were found', 'shaken'); ?></h2>
  237. <?php get_search_form(); ?>
  238. </div>
  239. </div><!-- #sort -->
  240. <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement