Advertisement
russapoth

artistpage

Dec 21st, 2012
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.52 KB | None | 0 0
  1. <?php
  2. /**
  3. * The Template for displaying all single posts.
  4. *
  5. * @package WordPress
  6. * @subpackage Twenty_Eleven
  7. * @since Twenty Eleven 1.0
  8. Template Name: Template Artwork
  9. */
  10.  
  11. get_header(); ?>
  12. <script type='text/javascript'>
  13. jQuery(document).ready(function() {
  14. var $container = jQuery('#artwork');
  15. $container.fadeIn();
  16.  
  17. $container.imagesLoaded( function(){
  18. $container.isotope({
  19. itemSelector : '.work',
  20. layoutMode : 'masonry',
  21. hiddenStyle: { opacity : 0, scale : 0.001, display: 'none' },
  22. visibleStyle: { opacity : 1, scale : 1, display: 'block' }
  23. });
  24. });
  25.  
  26. jQuery(".isotope-reset").click(function(){
  27. jQuery(".artwork").isotope({
  28. filter: '*',
  29. hiddenStyle: { opacity : 0, scale : 0.001, display: 'none' }
  30. });
  31. jQuery('[data-original]').each(function(){
  32. el = jQuery(this);
  33. el.html(el.data('original'));
  34. });
  35. });
  36.  
  37. var filtered_items;
  38. jQuery('#filters div ul#artist-names a, #filters div ul.wp-tag-cloud a').click(function(){
  39. filtered_items = [];
  40.  
  41. // set current column filter
  42. filter_link = jQuery(this);
  43. filter_text = filter_link.text().replace(' ', '');
  44. current_column = jQuery(this).closest('ul').siblings('span');
  45.  
  46. // set current filters
  47. if(filter_text == 'ShowAll') {
  48. original_title = current_column.data('original');
  49. current_column.text(original_title);
  50. current_column.data('current', '');
  51. } else {
  52. current_column.data('current', filter_text);
  53. }
  54.  
  55. // build array to join
  56. jQuery('[data-current]').each(function(){
  57. curr = jQuery(this).data('current');
  58. if(curr != '') {
  59. filtered_items.push(curr);
  60. }
  61. });
  62.  
  63. // if array isn't empty, join into a selector. otherwise select all w/'*'
  64. if(filtered_items.length){ filtered_items = '.' + filtered_items.join('.'); }
  65. else { filtered_items = '*'; }
  66.  
  67. // run isotope
  68. $container.isotope({ filter: filtered_items });
  69.  
  70. return false;
  71. });
  72.  
  73. jQuery('a.forsale').click(function(){
  74. $container.isotope({ filter: '.forsale' });
  75. return false;
  76. });
  77. });
  78. </script>
  79.  
  80. <section class="content full">
  81. <a href="#" class="forsale">Only Items for Sale</a>
  82. <a href="#" class="isotope-reset">Show All</a>
  83. <nav id="filters">
  84. <div>
  85. <span data-original="Artists" data-current="">Artists</span>
  86. <ul id="artist-names">
  87. <?php
  88. $wp_query = new WP_Query('post_type=artists&showposts=-1&orderby=ASC');
  89. while ($wp_query->have_posts()) :
  90. $wp_query->the_post();
  91. $name = $post->post_title;
  92. $str = preg_replace("/[^A-Za-z0-9]/","",$name); ?>
  93. <li><a href="<?php echo $str; ?>"><?php the_title(); ?></a></li><?php
  94. endwhile;
  95. rewind_posts();
  96. ?>
  97. </ul>
  98. </div>
  99. <div style="width: 25px; float: left;"> </div>
  100. <!-- <div>
  101. <span data-original="Color" data-current="">Color</span>
  102. <?php wp_tag_cloud( array( 'taxonomy' => 'colors', format => 'list' ) ); ?>
  103. </div> -->
  104. <div style="width: 25px; float: left;"> </div>
  105. <div>
  106. <span data-original="Medium" data-current="">Medium</span>
  107. <?php wp_tag_cloud( array( 'taxonomy' => 'medium', format => 'list' ) ); ?>
  108. </div>
  109. </nav>
  110.  
  111. <ul id="artwork" class="artwork">
  112. <?php
  113. $paged = (get_query_var('paged')) ? (int) get_query_var('paged') : 1;
  114. $artists = new WP_Query('post_type=artwork&showposts=-1&orderby=ASC');
  115. while ($artists->have_posts()) :
  116. $artists->the_post();
  117.  
  118. // Needs to be refactored
  119. $colors = the_simple_terms('colors') . ' ';
  120. $medium = the_simple_terms('medium') . ' ';
  121. $categories = the_simple_terms('categories');
  122.  
  123. //Find artists name, store them in $related
  124. $artistName = get_field('artwork_artist_name');
  125. foreach( $artistName as $related ){
  126. $name = $related->post_title;
  127. $str = preg_replace("/[^A-Za-z0-9]/","",$name);
  128. }
  129.  
  130. if( get_field('artwork_for_sale') ){
  131. $forSale = "forsale";
  132. } else {
  133. $forSale = "";
  134. } ?>
  135.  
  136. <li class="work group <?php echo $colors . $medium . $categories . ' ' . $str . ' ' . $forSale?>">
  137. <a href="<?php the_permalink(); ?>" rel="<?php echo the_ID(); ?>" class="postpopup">
  138. <?php $myimage = wp_get_attachment_image_src(get_field('artwork_photo'), 'artwork-store'); ?>
  139. <img class="photo" src="<?php echo $myimage[0]; ?>" alt="" />
  140. <p>
  141. <!-- <span class="title"><?php the_title(); ?></span>
  142. <span class="size"><?php the_field('artwork_dimensions'); ?></span> -->
  143. <span class="artist">
  144. <!-- <?php echo get_the_post_thumbnail( $related->ID, 'thumb-artwork' ); ?> -->
  145. <span>By: <?php echo $related->post_title; ?></span>
  146. </span>
  147. </p>
  148. </a>
  149. <!-- <?php if( get_field('artwork_for_sale') ) { the_field('paypal_button'); } ?> -->
  150. </li>
  151. <?php endwhile; ?>
  152. <?php rewind_posts(); ?>
  153. </ul>
  154. <div class="next-prev-links no-print">
  155. <div class="nav-left">
  156. <a href="/art/page/<?php echo $paged + 1; ?>">� Older Posts</a>
  157. </div>
  158. <?php if($paged != 1): ?>
  159. <div class="nav-right">
  160. <a href="/art/page/<?php echo $paged - 1; ?>">Newer posts �</a>
  161. </div>
  162. <?php endif; ?>
  163. <div class="clear"></div>
  164. </div>
  165. </section>
  166. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement