page_box.php 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <?php
  2. function get_page_box($attrs){
  3. global $count2 ;
  4. $box_title = "Collettivi/Progetti";
  5. if( !empty($attrs['title']) )
  6. $box_title = $attrs['title'];
  7. $Posts = 12;
  8. if( !empty($attrs['num']) )
  9. $Posts = $attrs['num'];
  10. $page_ids=Array();
  11. if( !empty($attrs['ids']) )
  12. $page_ids=explode(",",$attrs['ids']);
  13. $home_layout = '';
  14. if( !empty($attrs['layout']) )
  15. $home_layout = $attrs['layout'];
  16. $offset = '';
  17. if( !empty($attrs['offset']) )
  18. $home_layout = $attrs['offset'];
  19. $args=Array(
  20. 'post_type'=> 'page',
  21. 'post__in' => $page_ids,
  22. 'posts_per_page' => $Posts,
  23. 'offset'=> $offset,
  24. 'orderby' => 'rand'
  25. );
  26. $attrs['paged'] = 'y';
  27. if ( !empty( $attrs['paged'] ) && $attrs['paged'] == 'y' )
  28. $args[ 'paged' ] = get_query_var('paged');
  29. else $args[ 'no_found_rows' ] = 1 ;
  30. $cat_query = new WP_Query($args);
  31. $count = 0;
  32. ?>
  33. <?php if( $home_layout == '2c'): //************** 2C ****************************************************** ?>
  34. <?php $count2++; ?>
  35. <section class="cat-box column2 <?php if($count2 == 2) { echo 'last-column'; $count2=0; } ?>">
  36. <div class="cat-box-title">
  37. <h2><?php echo $box_title ; ?></h2>
  38. <div class="stripe-line"></div>
  39. </div>
  40. <!-- post-thumbnail /-->
  41. <div class="cat-box-content">
  42. <?php if($cat_query->have_posts()): ?>
  43. <ul>
  44. <?php while ( $cat_query->have_posts() ) : $cat_query->the_post(); $count ++ ;?>
  45. <?php if($count == 1) : ?>
  46. <li <?php tie_post_class('first-news'); ?>>
  47. <div class="inner-content">
  48. <?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) : ?>
  49. <div class="post-thumbnail">
  50. <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
  51. <?php tie_thumb( 'tie-medium' ); ?>
  52. <span class="overlay-icon"></span>
  53. </a>
  54. </div><!-- post-thumbnail /-->
  55. <?php endif; ?>
  56. <h2 class="post-box-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
  57. <div class="entry">
  58. <?php tie_excerpt_home() ?>
  59. <a class="more-link" href="<?php the_permalink() ?>"><?php _e( 'Read More &raquo;', 'tie' ) ?></a>
  60. </div>
  61. </div>
  62. </li><!-- .first-news -->
  63. <?php else: ?>
  64. <li <?php tie_post_class(); ?>>
  65. <?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) : ?>
  66. <div class="post-thumbnail">
  67. <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php tie_thumb(); ?><span class="overlay-icon"></span></a>
  68. </div><!-- post-thumbnail /-->
  69. <?php endif; ?>
  70. <h3 class="post-box-title">
  71. <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a>
  72. </h3>
  73. <div class="entry">
  74. <?php tie_excerpt_home() ?>
  75. </div>
  76. </li>
  77. <?php endif; ?>
  78. <?php endwhile;?>
  79. </ul>
  80. <div class="clear"></div>
  81. <?php endif; ?>
  82. </div><!-- .cat-box-content /-->
  83. </section> <!-- Two Columns -->
  84. <?php elseif( $home_layout == '1c' ): //************** 1C ****************************************************** ?>
  85. <section class="cat-box wide-box">
  86. <div class="cat-box-title">
  87. <h2><?php echo $box_title ; ?></h2>
  88. <div class="stripe-line"></div>
  89. </div><!-- post-thumbnail /-->
  90. <div class="cat-box-content">
  91. <?php if($cat_query->have_posts()): ?>
  92. <ul>
  93. <?php while ( $cat_query->have_posts() ) : $cat_query->the_post(); $count ++ ;?>
  94. <?php if($count == 1) : ?>
  95. <li <?php tie_post_class( 'first-news' ); ?>>
  96. <div class="inner-content">
  97. <?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) : ?>
  98. <div class="post-thumbnail">
  99. <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
  100. <?php tie_thumb( 'tie-large' ); ?>
  101. <span class="overlay-icon"></span>
  102. </a>
  103. </div><!-- post-thumbnail /-->
  104. <?php endif; ?>
  105. <h2 class="post-box-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
  106. <div class="entry">
  107. <?php tie_excerpt_home() ?>
  108. <a class="more-link" href="<?php the_permalink() ?>"><?php _e( 'Read More &raquo;', 'tie' ) ?></a>
  109. </div>
  110. </div>
  111. </li><!-- .first-news -->
  112. <?php else: ?>
  113. <li <?php tie_post_class(); ?>>
  114. <?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) : ?>
  115. <div class="post-thumbnail">
  116. <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php tie_thumb(); ?><span class="overlay-icon"></span></a>
  117. </div><!-- post-thumbnail /-->
  118. <?php endif; ?>
  119. <h3 class="post-box-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h3>
  120. <div class="entry">
  121. <?php tie_excerpt_home() ?>
  122. </div>
  123. </li>
  124. <?php endif; ?>
  125. <?php endwhile;?>
  126. </ul>
  127. <div class="clear"></div>
  128. <?php endif; ?>
  129. </div><!-- .cat-box-content /-->
  130. </section><!-- Wide Box -->
  131. <?php else : //************** list ********************************************************************************** ?>
  132. <section class="cat-box list-box">
  133. <div class="cat-box-title">
  134. <h2><?php echo $box_title ; ?></h2>
  135. <div class="stripe-line"></div>
  136. </div><!-- post-thumbnail /-->
  137. <div class="cat-box-content">
  138. <?php if($cat_query->have_posts()): ?>
  139. <ul>
  140. <?php while ( $cat_query->have_posts() ) : $cat_query->the_post(); $count ++ ;?>
  141. <?php if($count == 1) : ?>
  142. <li <?php tie_post_class( 'first-news' ); ?>>
  143. <?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) : ?>
  144. <div class="post-thumbnail">
  145. <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
  146. <?php tie_thumb( 'tie-medium' ); ?>
  147. <span class="overlay-icon"></span>
  148. </a>
  149. </div><!-- post-thumbnail /-->
  150. <?php endif; ?>
  151. <h2 class="post-box-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
  152. <div class="entry">
  153. <?php tie_excerpt_home() ?>
  154. <a class="more-link" href="<?php the_permalink() ?>"><?php _e( 'Read More &raquo;', 'tie' ) ?></a>
  155. </div>
  156. </li><!-- .first-news -->
  157. <?php else: ?>
  158. <li <?php tie_post_class( 'other-news' ); ?>>
  159. <?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) : ?>
  160. <div class="post-thumbnail">
  161. <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php tie_thumb(); ?><span class="overlay-icon"></span></a>
  162. </div><!-- post-thumbnail /-->
  163. <?php endif; ?>
  164. <h3 class="post-box-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h3>
  165. <div class="entry">
  166. <?php tie_excerpt_home() ?>
  167. </div>
  168. </li>
  169. <?php endif; ?>
  170. <?php endwhile;?>
  171. </ul>
  172. <div class="clear"></div>
  173. <?php endif; ?>
  174. </div><!-- .cat-box-content /-->
  175. </section><!-- List Box -->
  176. <?php endif; ?>
  177. <?php if ( !empty($attrs['paged'] ) && $attrs['paged'] == 'y'
  178. && empty($offset) && $cat_query->max_num_pages > 1){?>
  179. <div class="recent-box-pagination"><?php tie_pagenavi($cat_query , $Posts); ?> </div>
  180. <?php } ?>
  181. <div class="clear"></div>
  182. <?php } ?>