page_box.php 8.5 KB

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